anycable / graphql-anycable

A drop-in replacement for GraphQL ActionCable subscriptions. Works with AnyCable.
MIT License
112 stars 18 forks source link

Using a LUA script to write the subscriptions #30

Closed smasry closed 1 year ago

smasry commented 1 year ago

Using a LUA script to write the subscriptions to redis.

Envek commented 1 year ago

Hey, thanks for the pull request!

Why you decided to use Lua? Is there any performance bottleneck you hit into, and how much Lua improved the situation?

smasry commented 1 year ago

@Envek There are performance improvements using LUA. In testing we see a ~50% reduction from an average of 4ms to a 2ms when calling write_subscription with using a LUA script.

Envek commented 1 year ago

Oh, wow, drop from 4 to 2 ms is a lot. It is surprising, tbh.

Interesting, what Redis server are you using and how “far” it is from your application? High RTT can be a cause for this distinction.

Also, do you use broadcasting and how many subscriptions per fingerprint you have? I tried to optimize this use case in https://github.com/anycable/graphql-anycable/pull/28, but didn't finish yet (maybe it is related, not sure).