Today we're announcing the general public preview our new Peer To Peer network protocol.
There is more hardware in the world than ever before. As hardware proliferates, it becomes more powerful and produces more data at a velocity that is only increasing. With more than 16 billion mobile devices, 3 billion laptops, and countless IoT devices, the world is entering an era of ubiquitous computing; a thesis held by many experienced technologists for over a decade.
Cloud services and client-server based architectures have been a successful solution for high availability and on-demand computing and storage. But they have also demonstrated that, as scale up, they become more expensive, more complex, and less reliable.
P2P can reduce cost, complexity, and improve reliability by moving workloads out of the data-center and onto the end-points of the network. This also provides opportunities for improved privacy and security.
This is why we see P2P as the next chapter in the story of cloud computing.
P2P is a broad term that can include a lot of things. To create a framework for having a conversation, we like to break the problem space into 5 distinct areas,
Networking
,
Compute
,
Replication
,
Consensus
, and
Storage
. Today, we solve the Networking problem. We help you discover, connect, and communicate with peers in the most reliable way. This is the solid foundation that Web developers need to build interesting things in the other areas.
Latica Protocol
.
2171
lines of code.
Most P2P protocols produce isolated networks of participants — a problem when Alice wants to send a message to Bob when he is offline. Latica takes the opposite approach, creating a shared global network where each peer, regardless of who they know, help each other connect and relay packets without needing server infrastructure.
Since packets are encrypted and causally linked, they can be acquired by any peer in any order, and read only by the intended recipients.
Every peer in the network has exactly the same capabilities, and this symmetry makes it highly tolerant to failures and partitions. This also ensures that every peer continues to operate normally regardless of the condition of any other peers in the network.
The API uses an event emitter pattern so it should be immediately familiar to any JavaScript developer.
After importing the module, create (or read from storage) a peer ID and an ed25519 key-pair for signing packets that this peer creates.
__Note__ To make this example more readable, we don't save and read the peer's
ID. In practice, you should save it after creating it, and then read it from
where ever you saved it because you usually want a peer IDs to be deterministic
across application restarts.
Next, create (or read from storage) a clusterID. The purpose of this is to help peers in the network introduce you to peers who you know .
Don't actually use
'TEST'
, you most likely want to pick a unique seed or use a random values for these. If you don't, you may end up receiving unexpected messages with unexpected encodings from strangers.
Next, create the instance of the socket and pass the values you've created.
Before we create data for other peers in our network to receive, we should create a subcluster — this is a way to "bucket" the data in your cluster. In this case we will create a partition called
greetings
. Again, see the earlier note about persisting keys for determinism.
Now that we have that out of the way we can create a small program.
The way most people are using Latica is to augment their existing Cloud services and offload work to end-user hardware.
But any front-end developer familiar with HTML, CSS, and JavaScript should be able to create a fully functional chat app like Telegram, a social media app like Twitter, a coordination app like Uber, or a collaborative content creation app like Figma or Notion without needing any servers or Cloud services at all.
Contemporary client-server designs tend to keep the majority of intelligence off the client and in the data-center. In the many-to-few model, millions of clients connect to a small number of servers, a natural concurrency bottle-neck.
P2P is a many-to-many model, so concurrency is less of a concern. Intelligence is distributed equally in the network. Clients retain data and do compute that is relevant for them. This has better scaling properties and lower costs, and at the same time it doesn't preclude business intelligence or intellectual property.
Latica makes sure every peer is able to communicate with other peers directly or indirectly, regardless of the NAT type in front of it.
This is a high-level introduction to our early preview. But you can take a much deeper dive with our p2p guides . Our work derives from highly peer-reviewed computer science research and we cite our sources frequently.