3 ms·
I'll soon have to do a pub/sub for an application that's close to a multiplayer video game. Most advices I have seen say that I'll probably want to code it mys
by Iv 7y ago
I'll soon have to do a pub/sub for an application that's close to a multiplayer video game.
Most advices I have seen say that I'll probably want to code it myself, but I was wondering about the latency of that solution? I'll likely have a SQL store and that would be a good argument to use postgres...
- codesushi42 7y agoUse Redis pubsub instead.
- Iv 7y agoLooking into it, it seems to have something like 2ms of latency which is good. Do you think it would be a good idea to use for exchanging, say, realtime position of players in a virtual world?
- codesushi42 7y agoNot with pubsub. You could use it as shared memory store for player states though, I guess.
- kiwicopple 7y agoFor straight up pub/sub (without the job server), I tried NOTIFY/SUBSCRIBE in Postgresql, but hit some limitations. We have switched to an Phoenix (elixir) server which listens to the database, then clients subscribe via websockets. We're opensourcing it here: https://github.com/supabase/realtime https://github.com/supabase/realtime It's still in very early stages (although I am using it in production). Basically the Phoenix server listens to PostgreSQL's replication functionality and converts the byte stream into JSON, which it then broadcasts over websockets. This is great since you can scale the Phoenix servers without any additional load on your DB. Also it doesn't require wal2json (a Postgres extension). The beauty of listening to the replication functionality is that you can make changes to your database from anywhere - your api, directly in the DB, via a console etc - and you will still receive the changes via Phoenix.
- enoex1 7y agoRedis pub / sub has worked fantastically for me - reached 100k+ concurrent users with ~80 msg / sec, but benchmarked much higher. It was the easiest, fastest, and most reliable solution I found (about ~4 years ago)
- NicoJuicy 7y agoPerhaps checkout Nats, I'm very satisfied with it ( did pretty extensive research on finding a good message system) It's similar to Apache Kafka but very light on resources and easy to selfhost. Ow yeah, the throughput is around 150 k msg/s. Without much configuration.