OnFinality is a blockchain infrastructure platform that saves web3 builders time and makes developers’ lives easier. We deliver scalable API endpoints for the biggest blockchain networks and empower developers to automatically test, deploy, scale and monitor your own blockchain nodes within minutes.
In this case study, we dive into how our often-overlooked middleware shone during the Polkadot inscription craze of December 2023Summary
On December 21 2023, usage on the Polkadot Network exploded as users flocked to try out ordinal inscriptions. This resulted in over 1 million transactions on Polkadot in 24h, a record for the network.
Infrastructure and RPC providers across the ecosystem came under stress from record transactions and users, putting access to the blockchain at risk
Thanks to a series of bespoke features in OnFinality’s RPC Gateway, the increased traffic and user connections were served quickly with no downtime
What are Inscriptions
Inscriptions work by embedding information directly on-chain, commonly used to create NFTs on networks where they aren’t natively supported. The interest in inscriptions originally began on Bitcoin and has more recently expanded to other networks including Polkadot.
OnFinality’s RPC Endpoint
OnFinality provides Remote Procedure Call (RPC) API access to the Polkadot network.
When applications, such as wallets and explorers, need to read or write to the Polkadot Network they can do so through OnFinality’s RPC service - composed of a pool of shared Nodes distributed globally.
This saves teams time and money compared to running dedicated nodes themselves, and brings confidence that OnFinality’s service will seamlessly handle increased demand 24/7
What is an API Gateway
API Gateways sit between the user’s application and the pool of shared blockchain nodes. They are responsible for verifying that the request is valid and then routing it to a healthy node nearby to serve the request - reading data off the blockchain or writing a transaction.
With a typical blockchain RPC gateway, each user opens a new websocket connection directly with a single node and maintains that connection for the life of the session.
Websockets are prevalent in Polkadot due the ability to subscribe to changes in data and new events such as block creation or wallet balance changes - a more efficient approach compared to polling
What can go wrong?
The connected node is no longer able to handle requests for that user
Nodes can fail to respond for various reasons, such as a restart or high CPU and memory usage.
This will result in poor performance for any users connected to that node, and the Websocket may disconnect entirely
All nodes have used up their capacity for Websocket connections.
All blockchain nodes have a limit of how many active Websocket connections they can maintain.
When all nodes reach their limit new users will not be able to connect to that RPC service until another user disconnects.
How OnFinality’s Intelligent Gateway helps
Node Connection Pools
OnFinality’s gateway combines multiple users’ Websocket connections into one, reducing strain on the node and ensuring it doesn’t run into connection limitations.
It maintains a pool of connections to each node and recycles them as users come and go, greatly increasing our capacity for concurrent users.
Using Websocket subscriptions, applications can ask to be notified when a specific event happens on chain, for example:
“Let me know when each new block is created”
When we identify that multiple users want to be notified of the same event we don’t create a duplicate subscription to the node. Instead, we keep track of who has asked to be notified and with only one subscription we are able to send updates to many applications.
When the node a user is connected to becomes unhealthy we seamlessly swap them to another node without dropping the connection.
If they have a subscription open we will even recreate the subscription on the new node!
This results in more stable connections and fewer missed notifications.
OnFinality’s Gateway caches popular requests, responding near-instantly and reserving nodes for more intensive operations.
To know what can be cached, and for how long, we need to dig into the requesting method and its parameters to understand:
- Is the request a transaction or a query?
- Will the response to this query change?
- If so, how often does it change?
This can vary depending on many factors such as the block production time of the network and whether a new, unfinalized, block is being queried vs an archival block that will never change.
OnFinality processed 6 times the normal daily Polkadot usage on December 21st without needing to add additional nodes demonstrating the power of how the OnFinality platform makes it easier for developers to sleep at night.
Developer documentation: https://documentation.onfinality.io/support/ About OnFinalityOnFinality is a blockchain infrastructure platform that saves Web3 builders time and makes their lives easier. OnFinality delivers scalable API endpoints for the biggest blockchain networks and empowers developers to automatically test , deploy, scale and monitor their own blockchain nodes within minutes. To date, OnFinality has served over 250 billion RPC requests across 60 networks including Polkadot, Kusama, Moonbeam, Astar, Avalanche and Cosmos, and is continuously expanding these mission-critical services so developers can build the decentralised future, faster!