anycable-go
anycable-go copied to clipboard
[WIP] mRuby commands
What is the purpose of this pull request?
Add ability to perform Action Cable commands within anycable-go itself without calling RPC server.
That would allows us to increase RPS (requests-per-second) for RPC bridge (see the benchmarks).
To implement this caching we fetch (not implemented yet) the source code of the method and compile it within the embedded mRuby VM.
Benchmarks
Running anycable-go on the same machine as RPC server:
# websocket-bench echo
rpc_cached 95per-rtt: 5ms
rpc 95per-rtt: 30ms
# controller.Perform
rpc_cached 0.05ms
rpc 0.7ms
TODO
Features:
- [ ] Embed mRuby sources (https://github.com/gobuffalo/packr ?)
- [ ] Fetch method source from RPC
- [ ] Detect cacheable* commands
- [ ] Cache invalidation
* Not every channel command could be cached, of course. We need a way to either automatically guest whether it's possible to "move" the method to mRuby or to provide an API to mark such methods in the Ruby source code.
Misc:
- [x] mRuby memory profiling (GC arena save/restore?)
- [ ] Run benchmarks/stress test
- [ ] Add Changelog entry
- [ ] Update documentation for this change