[Atp] Repository throughput

Hi all,

I think it would be worthwhile to discuss scale assumptions for the Repository and PDS design. The AT Science community and others are beginning to use ATP for use cases well outside its original social network use cases, pushing the envelope on scale and throughput.

Two examples are Nebra (github.com/the-astrosky-ecosystem/nebra) for streaming real-time scientific instrument data over ATProto, and Matadisco (matadisco.org) for pushing dataset records into the network as a universal index layer. (If you are the authors of this or similar projects, please chime in with your use case.)

For example, a seismometer could transmit ~100 samples per second. In a 10-device deployment, this would write ~60,000 records per minute or 31 billion records per year. Batching would reduce that, but the spec’s guidance is a bit open-ended: Section 2 says implementations ā€œshould apply practical limits on batch sizesā€ without defining them, and Section 8.4.2 sets hard limits of 200 ops and 2MB per #commit message.

A few questions:

  1. Relay relationship: What is the mechanism for a high-throughput, domain-specific PDS to participate in ATP’s network without overwhelming full-network relays? Is there (or should there be) a way for a PDS to signal to relays that it should be crawled selectively?

  2. Commit frequency: The spec defines limits on the number of operations per commit (Section 8.4.2), but is there any guidance on commit rate?
    I see the recently published VLPDS (vlpds.jazco.dev) project addresses large-scale social deployments, but it appears to optimize for number of accounts and storage scalability, rather than ongoing high-frequency writes from a small number of accounts.

These questions may be out of scope for the 11-02 cutoff for IETF 127, but it seems worth raising now whether large, non-social use cases are in scope for this spec or better addressed in a separate profile or future document.

– Mosh

1 Like

Hi Mosh!

Two examples are Nebra (github.com/the-astrosky-ecosystem/nebra) for streaming real-time scientific instrument data over ATProto, and Matadisco (matadisco.org) for pushing dataset records into the network as a universal index layer. (If you are the authors of this or similar projects, please chime in with your use case.)

Another project I have seen is SensorThing (https://sensorthings.dev/#info), which publishes environmental sensor data as records.

I think all these use-cases are interesting, and hope we can find ways to accommodate them to some degree or another.

For example, a seismometer could transmit ~100 samples per second. In a 10-device deployment, this would write ~60,000 records per minute or 31 billion records per year. Batching would reduce that, but the spec’s guidance is a bit open-ended: Section 2 says implementations ā€œshould apply practical limits on batch sizesā€ without defining them, and Section 8.4.2 sets hard limits of 200 ops and 2MB per #commit message.

Another relevant metric is what the expected end-to-end latency is, and maybe the variance of that latency. The loose design goal has historically been ā€œsub-secondā€, and I think that the deployed network usually meets that goal (though I have not measured/confirmed in some time).

One thing that strikes me about the raw numbers is that they get close to audio waveforms (eg, 44 kHz). Would we expect to be able to stream radio or live audio over atproto? The experience and design patterns that https://stream.place/ has had with streaming video seems relevant. The worlds of network observability and time series metrics also feel relevant.

My guess is that most sensor data does not need to be low-latency. Nebra is an exception, but in that case might not need to be high throughput. Batching many data points in single records (eg, arrays of numbers) helps reduce storage even more than batching multiple record ops into a single commit. Domain-specific binary encoding and compression can have huge impacts on storage efficiency. Data could get rolled up in to larger file (HDF5 or Parquet?) and stored as atproto blobs that get referenced by small records. All these techniques would have trade-offs of course.

A few questions:

  1. Relay relationship: What is the mechanism for a high-throughput, domain-specific PDS to participate in ATP’s network without overwhelming full-network relays? Is there (or should there be) a way for a PDS to signal to relays that it should be crawled selectively?

The short answer is that there is no such mechanism right now.

Even if we didn’t add such a mechanism, it would probably be good to have things degrade or fail gracefully. For example, ways for PDS instances to understand if they have exceeded downstream limits.

  1. Commit frequency: The spec defines limits on the number of operations per commit (Section 8.4.2), but is there any guidance on commit rate?

There is no such guidance in the text right now.

I think it might be helpful to throw out some operational numbers and limits as context. I am not proposing that limits like these be added to any of the current documents, they are just to ground the discussion.

When talking about the size of individual repositories, the historic design goal was to work well with at least single-digit millions of records, and a few hundred MByte of total size (as a CAR export). I think there are larger repositories in the network today. Sometimes large repositories have caused operational friction, though some of these have been addressed with implementation performance improvements.

The PDS implementation developed by Bluesky includes rate-limits on repository operations by individual accounts. These are intended to constrain resource consumption by untrusted accounts. They work out to roughly 1,600 records created per hour, and separately 12,000 records per 24 hr. These are counted per record operation, not per commit.

The relay reference implementation developed by Bluesky includes message rate-limits per PDS which are computed based on an PDS account limit, which can be configured per PDS. These are not enforced per-account (though it might be an improvement to do it that way), and result in back-pressure (delayed processing) instead of dropping messages. The default limits are 50 msg/sec, 2,600 msg/hour, 21,000 msg/hour. These are per-message, not per-record.

The current full-network firehose runs between 200 msg/sec to 500 msg/sec over the course of a 24 hour diurnal cycle. The current Bluesky relay implementation was designed and tested up to around 20,000 msg/sec as a baseline (with spikes above that). Scaling to higher rates is a good topic for this working group. One option would be sharding over multiple concurrent connections.

These questions may be out of scope for the 11-02 cutoff for IETF 127, but it seems worth raising now whether large, non-social use cases are in scope for this spec or better addressed in a separate profile or future document.

I think these are great questions to be discussing! I think the protocol should try to accommodate as many use-cases as is reasonable. There are probably some pragmatic limitations, and it would be good to give hints at what those are. I’m particularly interested to learn from the IETF community what the best practices are around conveying operational limits which might change or evolve over time.

Part of the current charter is to produce documents ā€œdescribing operational considerations for deployment […]ā€. My interpretation of that would be a Best Current Practices (BCP) document, separate from any standard documents, which could convey things like ā€œreasonable default limits at the time of writingā€.

–bryan

These are definitely some really interesting use cases! I think that the most reasonable approach here would be to batch samples over a time period into a group record for a given second/minute/etc. - that way, you could also bundle in average/max/min values for the period and don’t have to worry as much about latency amounts. Any setup that would need truly-real-time data would be better served with a middleman that collects the live data and does the analysis/record batching instead of having the sensor post to the PDS directly from-device. You already need a gateway for LoRaWAN and other sensor-optimal communication standards, after all.

universal index layer

Forgive the philosophical distraction, but are these use cases for independent implementations​ of the protocol (in the RFC 2026 sense) or are these use cases on top of a single deployment of the protocol, assuming and requiring that all actors are tracked and indexed centrally by that single implementation?

Thanks,
__bf

Hi all,

This is good timing, incidentally I’m at a workshop this week where I’m trying to persuade the astronomy community to start using AT Protocol for streaming data (I’m developing nebra). For context, currently, there are four use cases in astronomy where AT Protocol fits in nicely:

  1. Streaming of rare transient events. A few times per day, something rare may happen (like a supernova) that everyone in the world needs to know about ASAP. These alerts may be produced by different instruments in different places, and it’s very useful to have them in one place, but on a decentralized protocol that no one government/agency controls. I’ve been rebroadcasting certain alert streams on-protocol, e.g. here. The sub-1s latencies are already as good as or better than existing solutions, the only sharp edge is that floating point numbers aren’t allowed (yet).

  2. Providing decentralized ways for anyone to publish analysis of an event in real-time. This is something I’m thinking about more lately, which works way better than anything we could do before - atproto’s backlinking makes this amazingly easy, and this is probably a much larger innovation than point 1 for us, IMO. Allowing anyone to publish instant follow-up analysis of something (e.g. running their own model and publishing the results in real-time) is awesome. This is a common use case in astro, and I’m sure in many other fields - it’s not just enough to know if something happened, but also to run and publish analysis about e.g. if it’s important enough to point a billion-euro telescope at it.

  3. You get an open database of past events ā€˜for free’. Most data streaming solutions in use right now in our field (like self-hosted Apache Kafka streams) save no or very little information, requiring third party services to index them and sometimes causing data loss long-term - the fact that a PDS is basically an API endpoint for a database is a huge asset. Many existing services don’t have any archive at all right now, and if they were on atproto then the PDS would do automatically.

  4. Citizen science. Again, anyone being able to post following any schema and in real-time is incredible, and this feeds into many other areas (I think biologists are way ahead here, see e.g. lexicons.bio). I’m super excited to see how decentralized science could develop here.

I think the thing that doesn’t fit in so well is as Mosh said, and relates to doing things at large scales. To give some real-world examples from astronomy: certain observatories are on the cusp of producing very high event rates, e.g. the Vera Rubin observatory, which will hit ~10 million events / day (close to the ~25 million already on the network). Most of these events can be pre-filtered, so we can find ways to not have to swamp the network with science data, but I still have lingering questions:

  • If we post a filtered list of 100k events / day, how will that work long-term? For starters, repositories are intended to store ā€œsingle-digit millions of recordsā€, but I don’t know where that limitation comes from (merkle search tree scaling issues?) and if workarounds could be built with different PDS implementations. Heck, I feel like even just people who post and like a lot on Bluesky will surely hit the ā€˜single-digit millions’ limit eventually. Is there a way that that limitation could be worked around, aside from ā€˜ugly hacks’ like making a new account whenever one fills up with too many records?

  • Are partial-network relays something we could endorse? An issue I’m seeing is that smaller PDSes get crawled less often than big ones, so https://astrosky.social (which I’ve been posting some transients from) seems to get events picked up by relays less frequently than the main Bluesky or Eurosky relays, which is a shame as using our own PDS feels more correct and in the spirit of the protocol than relying on a third party. Unless it’s a config issue I caused somewhere, I’d be interested in spinning a dedicated data relay that contains a subset of PDSes in use for low-latency data streaming, which I would guess could probably hit latencies consistently far below 1 second vs. a relay that has to do the whole network.

  • Definitions of network use vs. abuse. Again echoing what Mosh said, I don’t think there’s really a process for getting permission to post high data volumes aside from messaging relay operators and asking to not get rate limited. This will get progressively harder as time goes on, as more scientific purposes decide to post on the protocol, and as more providers start offering relays. Maybe the IETF isn’t the right venue here, but I think that thinking through how people with more niche data-heavy use cases should get collective permission to do their project on the protocol would be good.

Happy to see this discussed more. I already feel like I’ve only heard positivity when posting scientific data on-protocol (which is great!), but to reiterate some motivation: I think that welcoming scientific data onto the protocol benefits everyone, and allows the protocol to be a lot more than ā€˜only’ a social media thing. Given the issues around e.g. funding FOSS software right now, maybe that could, for instance, help people in the ecosystem tap into some funding sources that are geared towards scientific applications.

Emily

4 Likes