Robocorp 3.2.0: Control Room connections are reused in work items, vault and asset storage
Control Room connections are reused
robocorp-workitems 1.6.0, robocorp-vault 1.5.0 and robocorp-storage 1.2.0 now
keep their HTTPS connections to Control Room open between calls
(#501,
#502). Until now every call opened a new
connection, so each one paid for a TCP and TLS handshake before Control Room did any work.
Processing one work item takes about five calls (reserve, load the payload, list the files,
create an output, release), so a 1500-item run opened about 7,500 connections.
The further the robot runs from its Control Room region, the more those handshakes cost. The same robot processed 1500 work items from a machine about 68 ms away from Control Room:
| robocorp-workitems 1.5.1 | With connection reuse | |
|---|---|---|
| Total run | 2656 s (44 min) | 788 s (13 min) |
| Fetch the next input (3 calls) | 0.93 s | 0.30 s |
| Create an output | 0.44 s | 0.11 s |
| Release an input as done | 0.42 s | 0.11 s |
Each call dropped from 0.3–0.44 s to about 0.1 s. Robots close to Control Room gain less per call, but they skip the same handshakes.
Nothing changes in how you use the libraries. Vault and asset storage make fewer calls than work items, so the difference there is smaller: it shows when a robot reads several secrets in a row, and when it sets an asset, which makes several calls and then checks the upload status every half second.
Idle connections are reopened
A firewall or NAT on the network path can drop an idle connection without telling either side, and a request sent on such a connection waits for the full request timeout. To avoid that, a connection that has been unused for more than 30 seconds is closed, and the next call opens a new one. A robot that works for minutes between calls therefore pays one handshake after each pause, as it did before, and reuses the connection for calls made back to back.
The limit is set with the RC_API_CONNECTION_MAX_IDLE environment variable:
| Variable | Default | Effect |
|---|---|---|
RC_API_CONNECTION_MAX_IDLE | 30 | Seconds a connection can stay unused and still be reused. 0 opens a new connection for every call, as earlier versions did. |
RC_API_REQUEST_TIMEOUT | 60 | Seconds to wait for a connection or a response before the call fails and is retried. Unchanged in this release. |
Both are read when the library is imported, so set them in the environment the robot starts in. Each library has a new guide that covers these settings: work items, vault and asset storage.
Upgrading
robocorp 3.2.0 pins the three new versions, so upgrading the meta package is enough:
Released packages
- package
robocorp3.2.0 (meta package) - package
robocorp-workitems1.6.0 - package
robocorp-vault1.5.0 - package
robocorp-storage1.2.0