Chapter 4: Pace the calls with a rate limiter
Chapter 4 of the Orchesty onboarding series: import the demo-limiter topology and use the platform Limiter to throttle a batch fan-out to a safe pace, configured entirely on the application with no code.
In Chapter 3 a single run fanned out up to 100 downstream messages at once. Real APIs cap how fast you may call them, so now you'll import a topology that paces that same fan-out with the platform Limiter.
By the end you'll be able to throttle a whole flow to a safe rate without writing any code.
Prerequisites #
Nothing new to set up. Reuse the pieces from the earlier chapters: the mock server is running and the Products Test (Simulation) application is installed, authorized, and active.
What's new in this chapter #
Limiter. A keyed throttle the platform applies between your worker and the rest of the system. You configure it as pure application settings (no code), and the platform paces every app-bound node automatically, including the connector that runs after a batch fan-out. When the rate is reached the surplus messages are held and drain over time (backpressure), rather than failing. Background: Rate limiting.
The topology reuses the batch from Chapter 3 and adds a tiny mapper (products-test-extract-id) that trims each listed product to { id }, so the products-test-get-product connector can re-fetch it one by one. That per-item connector is what the Limiter paces.
Import and run #
Import demo-limiter.tplg.json from the demo worker's src/topologies/ folder, then Publish and Enable it.
Turn the Limiter on for the application (this is the whole point of the chapter):
- Open the Products Test (Simulation) application and go to its Limiter tab.
- Enable Use limit and set a low rate for a visible effect, for example 10 requests per 60 seconds, then Save.
Now trigger the topology manually from the Cron node. Send nothing to process the full default catalog (100 products), or pass a small cap for a quicker run:
{ "maxProducts": 50 }
The batch pages through the catalog and fans out one message per product, but the connector no longer runs them all at once: it fires at the configured rate while the rest wait their turn. The application's Limiter view shows how many messages are queued and an estimated time to drain.
The Limiter here is only configuration on the application; no node calls anything in code to make it work. Because the platform owns the throttle, it applies even across the batch fan-out to the downstream connector.
Drop a breakpoint anywhere if you want to watch messages waiting and then being released at the capped pace. For this small catalog it's safe; if you raise the catalog size, remove it (or lower maxProducts).
Where next #
So far every topology started on a schedule or a manual run. In Chapter 5 you'll import the demo-webhook topology and start a flow from an incoming event instead, using a Webhook trigger.
Want to read the code behind this chapter? Browse the demo worker on GitHub: Orchesty/orchesty-demo-worker. The batch and connector live in src/ProductsTest/Connector/, the mapper in src/ProductsTest/CustomNode/. Note the Limiter itself has no code; it's configured on the application in the Admin UI.