108 points · by yasserf · 7y ago · 37 comments
A non-IP based routing mechanism requires some kind of header/parsing/deserialization of the message being passed. In application level code this is quite slow, you have to query some kind of map synchronized about cluster nodes. This is especially shitty if message addresses are ephemeral, especially per RPC call (which is the default behaviour in most cluster-based RPC frameworks), because then your near cache of the cluster map is never populated. Alternatively you can just broadcast to everyone (skip the cluster map) but then why cluster?
It would be great if we just had IPv6 adoption though. Then you could just uh, route. The DNS based routing in stuff like Kubernetes is close but not for external Internet facing clients. The whole point is to avoid a bastion host.
I am assuming the RPC is happening over WebSockets though.
Generally deepstream is an alternative to using firebase, socket.io, featherJS and meteor. However rather than putting the logic within the server you instead run them as microservices and allow deepstream to handle load-balancing for you.
The two main things deepstream offers are:
- Events
You can publish and subscribe to events by simple doing:
deepstream.event.emit('event-name', data)
deepstream.event.subscribe('event-name', data => {})
Which is the functionality you expect to see from most pubsub mechanisms
- Records
Records is events with persistence. They are more heavy weight objects that persist their content in a cache + db and across all connected devices without the user/developer having to actually do anything. The also support offline support if you want to be able to get/set data while offline.
// get a record
const record = client.record.getRecord('unique-data-name')
// wait for record to be loaded from server
await record.whenReady()
// subscribe to any changes that happen in the future
record.subscribe(data => console.log('someone updated this object!', data)
// discard when finished
record.discard()
You can also set data directly without having to subscribe using
client.record.setData('some-record', newData)
The are multiple other aspects deepstream provides like merge-conflicts, permissions, authentication and some useful patterns, but the above code is about 90% of what you would expect a user to use in deepstream
Also supports persistence of data records (JSON docs) and syncing changes to those docs (competitive to Firebase, etc), backed by Redis.
Works with different protocols (websocket, MQTT, HTTP) and has client libraries for popular languages.
> deepstream is an open source server inspired by concepts behind financial trading technology. It allows clients and backend services to sync data, send messages and make rpcs at very high speed and scale.
https://landscape.cncf.io/category=streaming-messaging&forma...
It's the the 24th streaming & messaging project or product we're tracking.
Is it possible to make it work in a way that the server only sees encrypted data? I can see it working in a clunky kind of way if each client had two versions of each document, a clear one that is operated on, and one encrypted (possibly a record at a time or something) that is synced.
Ideally you would just configure it using a config file for your permissions (https://deepstream.io/tutorials/core/permission/valve-introd...) and use http auth to authenticate your users (https://deepstream.io/tutorials/core/auth/http-webhook/).
You can see this sort of configuration here https://deepstream.io/guides/live-progress-bar/
If you want you could add a custom plugin that would take the HTTP server within deepstream and enhance it using express for all your non-deepstream routes, if you raise an issue for it I think it's something that can be done in the near future! But generally wouldn't recommend for non-pet projects since they serve two different purposes.
Edit: Also thank you!
> deepstream is an open source server inspired by concepts behind financial trading technology. It allows clients and backend services to sync data, send messages and make rpcs at very high speed and scale.
https://vimeo.com/143728632 was what led to deepstream being initially written a few years back