Make sessions faster and cheaper
A session costs browser time for as long as it is open, and proxy bandwidth and CAPTCHA solves when it uses them. Pricing has the rates. Most of a run's cost and time comes from a few habits: a session that stays open after its work ends, pages that load more than the task needs, and steps that every run repeats. Go through the items below, and compare a run's cost before and after each change.
Release sessions on time
- Release each session as soon as its work ends. Steel bills a session until it is released or it times out. Release it in a
finallyblock, so that an error does not leave it open. See Always release sessions. - Let idle sessions end on their own. Set
inactivityTimeout, so that a session that your code forgets ends after a short time without activity. See Release idle sessions.
Load less
- Block what the task does not need. Steel blocks ads by default. Set
optimizeBandwidthtotrueto block images, media and stylesheets as well, or block the hosts that you choose. Pages load faster, and a session on a Steel proxy uses less bandwidth. Keep stylesheets for a task that needs the page to look right, such as a screenshot. See Reduce bandwidth.
Skip the sign-in
- Start each run signed in. Sign in once, save the browser as a profile, and start the next sessions from it with
profileId. Each run then skips the sign-in steps, and the site sees a browser that it knows instead of a new login. See Stay signed in across sessions.
Turn on paid features only where they help
- Add a proxy only for the sites that need one. A session without a proxy uses no proxy bandwidth. When a site needs a proxy and you have one, bringing your own adds no proxy bandwidth charge. See Bring your own proxy.
- Keep one address for a site that checks it. A site that sees a sign-in from a new address can ask for another check, which costs time and can cost a CAPTCHA solve. A dedicated IP keeps one address from one session to the next, for a monthly price for each IP. See Plans and pricing.
- Solve only the CAPTCHAs that block the task. With
solveCaptchaon, Steel solves each CAPTCHA that it detects, and each solve is billed. To choose which ones to solve, setstealthConfig.autoCaptchaSolvingtofalseand ask for each solve yourself. See Solve on request.
Measure the result
- Read what a session cost. The API returns each session's cost and the usage behind it, so you can compare runs before and after a change. See Session cost.
- Add up the cost by customer or by job. Tag sessions with metadata, and add up their costs. See Track cost per customer.
Next steps
- Prepare for productionCheck your keys, timeouts, retries, limits, cost, security and monitoring before you go live.
- Run sessions at scaleQueue work behind your concurrency limit, and retry and release sessions safely.
- PricingSee each plan's price and its rates for browser hours, proxy bandwidth and CAPTCHA solves.