Background
Anyone with enough backend experience will know that reverse proxy or API gateway is almost a must-have component for any public large scale API services. However, to my surprise, I still cannot find a production ready API Gateway with decent JSON RPC support.
Without API Gateway, it is hard to scale RPC servers as create a new node is very expensive and time-consuming. It is simply not feasible to scale out RPC nodes base on real-time demand. As a result, we need to over-provisioning RPC nodes and that is costly.
It is also relatively easy to DOS RPC nodes, as there are some RPC calls could be resource intensive. Substrate is not designed to run as a robust RPC server, which requires features like rate limiting and response caching.
Subway: Substrate JSON RPC Gateway
Subway aims to fill the missing gap by offering a high performance JSON RPC API Gateway with features specifically built for Substrate and Ethereum RPC.
Repo: https://github.com/AcalaNetwork/subway
Features
- Multiple upstream node for failover and load balancing
- Cache responses to reduce upstream node load
- Merge identical subscriptions to reduce upstream node load (WIP)
- Rate limiting for DOS prevention (WIP)
- Advanced RPC call filtering (WIP)
- e.g. filter what runtime call are allowed for
state_call
- e.g. filter what runtime call are allowed for
- High performance (it is written in Rust so it must be fast )
Subway is only two weeks old and missing a lot of features to be production ready. However I do believe it could significantly improve RPC services and reduce infrastructure cost.
Let me know if you have any feedbacks and if you happen to enjoy writing async Rust, contributions are also welcome!