e2b-dev / E2B

Secure open source cloud runtime for AI apps & AI agents
https://e2b.dev/docs
Apache License 2.0
7.02k stars 458 forks source link

add keepAlive docs for cumulative #346

Closed im-calvin closed 7 months ago

changeset-bot[bot] commented 7 months ago

⚠️ No Changeset found

Latest commit: 38baa6fb3321e6dcb26f482bcd67fa945a809eaf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

jakubno commented 7 months ago

Thanks @im-calvin for your PR. How keepAlive works can be little confusing. Actually it's not cumulative, it just takes maximum of current time to live and the required duration.

What can make it confusing is how we internally handle inactive sandboxes. The SDK sends ping every 5 seconds, if API receive the ping it won't kill the sandbox for next 15 seconds (it's like health check and if it's missing 3 times, the sandboxed is considered abandoned).

im-calvin commented 7 months ago

Question then, on the docs it says that there is a maximum sandbox limit of 1 hours. Is that just for the keepAlive function call or is that an internal limit imposed by you guys

For example, if I call keepAlive 3 times does that make my sandbox live for a total of three hours or just one?

jakubno commented 7 months ago

It's internal, sandbox lifetime can't exceed the maximum. If you call to extend the lifetime for another hour and the sandbox is already alive for 30 minutes. It will cap it to the maximum, aka extend the lifetime just by 30 minutes.

im-calvin commented 7 months ago

Cool thanks for clarifying saves me writing a test to figure that out myself. Is there any way of implementing that feature that I just outlined?

jakubno commented 7 months ago

The 1 hour limit is a limit for base tier, there's possibility to go Pro tier, more info here.

Would you share what are you working on? Also are you on our discord?