7 ms·
Cloudflare Sandbox SDK
- fishmicrowaver 1y agoIs there some sort of competition for awful looking websites going on?
- Svoka 1y agoI thought it was cute and easy to read.
- fishmicrowaver 1y agoThey didn't test it with FF apparently.
- fidotron 1y agoThis bizarre anti-aesthetic has been pushed in the web devex space for a few years now to appeal to other web devex companies.
- deleted 1y ago[deleted]
- _pdp_ 1y agoLooks nice. We rolled out our own that does pretty much the same thing but perhaps more because our solution can also mount persistent storage that can be carried between multiple runners. It does take 1-5 seconds to boot the environment (firecracker vms). If this sandbox is faster I will instruct the team to consider for fast starup. This is also very similar to Vercel's sandbox thing. The same technology? What I don't like about this approach is the github repo bootstrap setup. Is it more convenient compared to docker images pushed to some registry? Perhaps. But docker benefits from having all the artefacts prebuilt in advance, which in our case is quite a bit.
- _pdp_ 1y agoI browsed through the documents but it does not seem to be possible to auto destroy a sandbox after certain amount of idle time. This forces who ever is implementing this to do their own cleanup. It is kind of missed opportunity if you ask me as this is a big pain. It is sold as fire and forget but it seems that more serious workflows will require also a lot of supporting infrastructure.
- alooPotato 1y agoYou can easily set an alarm in the durable object to check if it should be killed and then call destroy yourself. Just a couple lines of code.
- _pdp_ 1y agoNice. Thanks for the tip. I did not know that this was a thing. I will look it up.
- ATechGuy 1y ago> It does take 1-5 seconds to boot the environment (firecracker vms). I'd say 1-5 secs is fast. Curious to know what use cases require faster boot up, and today suffer from this latency?
- _pdp_ 1y agoWhen your agent performs 20 tasks saving seconds here and there becomes a very big deal. I cannot even begin to describe how much time we've spent on optimising code paths to make the overall execution fast. Last week I was on a call with a customer. They where running OpenAI side-by-side with our solution. I was pleased that we managed to fulfil the request under a minute while OpenAI took 4.5 minutes. The LLM is not the biggest contributor to latency in my opinion.
- ATechGuy 1y agoThanks! While I agree with you on "saving seconds" and overall latency argument, according to my understanding, most agentic use cases are asynchronous and VM boot up time may just be a tiny fraction of overall task execution time (e.g., deep research and similar long running tasks in the background).
- fidotron 1y agoDoes this relate to workerd in any way or is it something else entirely?
- ZiiS 1y agoThe `getSandbox(env.Sandbox, "test-env");` code is running in workerd.
- whoiskatrin 1y agoIf anyone is curious, more details on our SDK can be found here actually https://github.com/cloudflare/sandbox-sdk https://github.com/cloudflare/sandbox-sdk
- alooPotato 1y agoMind answering the question here: https://news.ycombinator.com/item?id=45611301 https://news.ycombinator.com/item?id=45611301 ?
- ChrisArchitect 1y agoThese CF website relaunches are just that right? Workers last week (https://workers.cloudflare.com https://workers.cloudflare.com) and now this one yesterday. I mean, if CF has something newsworthy here they should do a blog post announcing it because otherwise it's just a refreshed website. It's hard to tell if there's anything new here. It's the same SDK stuff from earlier this year right? https://developers.cloudflare.com/changelog/2025-06-24-announcing-sandboxes/ https://developers.cloudflare.com/changelog/2025-06-24-annou...
- whoiskatrin 1y agoit barely had any features then, this version is full of new functionality: streaming logs, long running processes, code interpreter and lots of other things and full docs site as well
- holografix 1y agoThere’s also the changelog https://developers.cloudflare.com/changelog/ https://developers.cloudflare.com/changelog/
- dgb23 1y agoThe workers website looks extremely based. Love the evocative animations and it manages to still be readable and well organized.
- simonw 1y agoLooks like there's one feature missing from this that I care about: I'd like more finely grained control over what outbound internet connections code running on the box can make. As far as I can tell it's all or nothing right now: this.ctx.container.start({ enableInternet: false, }); I want to run untrusted code (from users or LLMs) in these containers, and I'd like to avoid someone malicious using my container to launch attacks against other sites from them. As such, I'd like to be able to allow-list just specific network points. Maybe I'm OK with the container talking to an API I provide but not to the world at wide. Or perhaps I'm OK with it fetching data from npm and PyPI but I don't want it to be able to access anything else (a common pattern these days, e.g. Claude's Code Interpreter does this.)
- paxys 1y agoThis simple feature bumps up the complexity of such a firewall by several orders of magnitude, which is why no similar runtime (like Deno) offers it. Networking as a whole can easily be controlled by the OS or any intermediate layer. For controlling access to specific sites you need to either filter it at the DNS level, which can be trivially bypassed, or bake something into the application binary itself. But if you are enabling untrusted code and giving that code access to a TCP channel then it is effectively impossible to restrict what it can or cannot access.
- navanchauhan 1y agoAt least on macOS, there is a third way where you can control the network connection on the PID/binary level by setting up a network system extension and then setting up a content filter so you can allow/deny requests. It is pretty trivial to set this up, but the real challenge is usually in how you want to express your rules. Little Snitch does this pretty well: https://www.obdev.at/products/littlesnitch/index.html https://www.obdev.at/products/littlesnitch/index.html
- simonw 1y agoThe most convincing implementation I've seen of this so far is to lock down access to just a single IP address, then run an HTTP proxy server at that IP address which can control what sites can be proxied to. Then inject HTTP_PROXY and HTTPS_PROXY environment variables so tools running in the sandbox know what to use.
- eis 1y agoCloudflare Containers (and therefore Sandbox) pricing is way too expensive. The pricing is a bit cumbersome to understand by being inconsistent with pricing of other Cloudflare products in terms of units and split between memory, cpu and disk instead of combined per instance. The worst is that it is given in these tiny fractions per second. Memory: $0.0000025 per additional GiB-second vCPU: $0.000020 per additional vCPU-second Disk: $0.00000007 per additional GB-second The smaller instance types have super low processing power by getting a fraction of a vCPU. But if you calculate the monthly cost then it comes to: Memory: $6.48 per GB vCPU: $51.84 per vCPU (!!!) Disk: $0.18 per GB These prices are more expensive than the already expensive prices of the big cloud providers. For example a t2d-standard-2 on GCP with 2 vCPUs and 8GB with 16GB storage would cost $63.28 per month while the standard-3 instance on CF would cost a whopping $51.84 + $103.68 + $2.90 = $158.42, about 2.5x the price. Cloudflare Containers also don't have peristent storage and are by design intended to shut down if not used but I could then also go for a spot vm on GCP which would bring the price down to $9.27 which is less than 6% of the CF container cost and I get persistent storage plus a ton of other features on top. What am I missing?
- ATechGuy 1y agoStartups would build on big tech, so are likely to add their margins. Have you looked into (bulk) discounts from GCP/AWS?
- Imustaskforhelp 1y agoCloudflare containers feel a lot more pricey as compared to workers but I think that it could provide more streamlined experience imo but still, If we are talking about complete cost analysis, sometimes I wonder how much cf containers vs workers vs hetzner/dedicated/shared vps / gcp etc. would work out for the same thing. Honestly, the more I think about it, my ease of sanity either wants me to use hetzner/others for golang/other binary related stuff and for the frontend to use cf workers with sveltekit That way we could have the best in both worlds and probably glue together somethings using proto-buf or something but I guess people don't like managing two codebases but I think that sveltekit is a pleasure to work with and can easily be learnt by anybody in 3-4 weeks and maybe some more for golang but yeah I might look more into cf containers/gcp or whatever but my heart wants hetzner for backend with golang if need be and to try to extract as much juice as I can in cf workers with sveltekit in the meanwhile. Thoughts on my stack?
- alooPotato 1y agoThere is an open question about how file persistence works. The docs claim they persist the filesystem even when they move the container to an idle state but its unclear exactly what that means - https://github.com/cloudflare/sandbox-sdk/issues/102 https://github.com/cloudflare/sandbox-sdk/issues/102
- SparkyMcUnicorn 1y agoTo me, the docs answer it pretty clearly. The defined directories persist until you destroy(). The part that's unclear to me is how billing works for a sandbox's disk that's asleep, because container disks are ephemeral and don't survive sleep[2] but the sandbox pricing points you to containers which says "Charges stop after the container instance goes to sleep". https://developers.cloudflare.com/sandbox/concepts/sandboxes/#idle https://developers.cloudflare.com/sandbox/concepts/sandboxes... https://developers.cloudflare.com/sandbox/concepts/sandboxes/#persistence https://developers.cloudflare.com/sandbox/concepts/sandboxes... [2] https://developers.cloudflare.com/containers/faq/#is-disk-persistent-what-happens-to-my-disk-when-my-container-sleeps https://developers.cloudflare.com/containers/faq/#is-disk-pe...
- alooPotato 1y agoYeah thats basically the issue. If container disks are ephemeral, how are they persisting it? And however they are doing it, whats the billing for it?
- ZiiS 1y agoSandbox is built on top of their Durable Objects; the underlying storage is $0.20/ GB-month.
- alooPotato 1y agoYou’re saying the file system in the container is persisted to the durable object storage? That doesn’t sound right.
- 1y ago
- jasonriddle 1y agoThis looks interesting. Instead of having to code this up using typescript, is there an MCP server or API endpoint I can use? Basically, I want to connect an MCP server to an agent, tell it it can run typescript code in order to solve a problem or verify something.
- ozeron 1y agoHey, I'm building a similar thing to sandbox SDK Are you interested in code execution only, or something else? File operations, git checkout etc?
- orliesaurus 1y agoHow much `power` do they have?
- serkanh 1y agoThis looks rough for e2b.dev, Beam, and others in this space. Even with e2b's fresh $20M raise, taking on Cloudflare is going to be tough.
- deleted 1y ago[deleted]
- taherchhabra 1y agoCan I run claude code or codex inside this
- nc 1y agoYou can in Cloudflare containers
- whoiskatrin 1y agoYes, you can, we will publish an example soon
- dustbunny 1y agoCloudflares docs are written so hard for web dev. Can you host a monolith app that isn't serving http traffic on cloudflare tech like containers? Like can you spawn a container and have it handle tcp or udp connections until you manually shut it down? The container docs say they auto shutdown after not receiving requests...
- grrowl 1y agoIt's a really good platform for Typescript microservices which scale-to-zero (up to very high theoretical limits), but it wouldn't be a platform you'd migrate a monolith PHP app to (for example).
- isodev 1y agoNo thanks, way too many things running Cloudflare already
- freakynit 1y agoThe pricing with such offerings is the biggest throwoff. This one comes out to be more than $58/month for just 1vCpu and 1GiB RAM when used continuously. Compare this with instances from Hetzner or Contabo or the likes. They are 35+ times cheaper. This means my total usage across entire month on cloudflare sandbox cannot cross even one single day of non-stop usage, just to break-even with hetzner/contabo/others.
- bluelightning2k 1y agoThat's like comparing any serverless offering to a continuously running host. Continuously running means you're doing it wrong / it's a bad fit. But yes the ratio is somewhat extreme.
- freakynit 1y agoIdeal when traffic is sporadic.
- thegeomaster 1y agoIt's interesting to also compare this to getting a bare metal instance and provisioning microVMs on it using Firecracker. (Obviously something you shouldn't roll yourself in most cases.) You can get a bare metal AX162 from Hetzner for 200 EUR/mo, with 48 cores and 128GB of RAM. For 4:1 virtual:physical oversubscription, you could run 192 guests on such a machine, yielding a cost of 200/192 = 1.04 EUR/mo, and giving each guest a bit over 1GiB of RAM. Interestingly, that's not groundbreakingly cheaper than just getting one of Hetzner's virtual machines!
- freakynit 1y ago"Interestingly, that's not groundbreakingly cheaper than just getting one of Hetzner's virtual machines!" .... yea.. cause this is what these companies are doing behind the scenes :)
- csomar 1y agoCloudflare bills by CPU time. You'll come up on top if you have very irregular traffic as Hetzner bills you 24/7 for your instance.
- asim 1y agoMy one annoyance with cloudflare. Everything is JavaScript. Every example, all the things. But I guess that's catering to their audience. Over the past year you could definitely seem them shift their services more inline with other cloud providers because that's the inevitable requirement to penetrate enterprise and a broader audience. But part of that should require opening up to a bigger audience from a language perspective too e.g backend languages. One time I'd like to see a Go example first or even a tabbed example. Just my opinion.
- ZiiS 1y agoThis code has to run inside their Worker's platform; _technically_ you can compile Go to WASM and get it to run; but practically it is Javascript only.
- xd1936 1y agoPython for Workers is coming eventually. https://developers.cloudflare.com/workers/languages/python/ https://developers.cloudflare.com/workers/languages/python/ https://blog.cloudflare.com/python-workers/ https://blog.cloudflare.com/python-workers/
- kentonv 1y agoIt's already live. Has been available for a while.
- ameliaquining 1y agoIIUC this particular product runs in Linux containers, not in V8 isolates like Workers uses. The upside of this is broader ecosystem compatibility (you can use whatever language you want even if it doesn't compile efficiently to Wasm); the downside is that each container instance runs in a particular data center and you have to worry about the latency implications of that, whereas every Worker runs in every location.
- ZiiS 1y ago
- nnx 1y agoIt's sad to see Cloudflare slowly adding egress fees to their new services. It was a core differentiator to never* have to worry about egress with them. *: unless it's so large that it borders on abuse or require a larger plan
- gorset 1y agoI agree. It’s the enshittification of the internet. Luckily we still have infrastructure providers with more sensible offerings. We don’t have to use aws, gcp, etc.
- sprobertson 1y agoWho's the designer? I assume the same as agents.cloudflare.com, finally something that looks creative and not based on purple gradients
- whoiskatrin 1y agoNanda is a great! https://x.com/nandafyi?s=21&t=eqRzxHltMiNrLXlna5kBEQ https://x.com/nandafyi?s=21&t=eqRzxHltMiNrLXlna5kBEQ
- wahnfrieden 1y agoI’ll never use metered Cloudflare services. Just reckless to expose myself to the hazard of mega bills for small mistakes or DoS attacks. I wish more companies allowed prepayment for plans like Bunny.net does.
- ozeron 1y agoLooking at pricing for this and especially for E2B. I've decided to work on a lightweight alternative to Cloudflare’s Sandbox because I ran into the same pain points with current solutions: - limited parallelization - expensive My focus is: - simple SDK primitives for code execution, file ops, and git checkout—no boilerplate stacks - transparent pricing (per-second compute with monthly caps, no surprise egress) - price sandboxes for 50-60% less then competitors Would love to get your feedback in https://usesandbox.dev/ https://usesandbox.dev/ Just finalized main pieces today
- aperture147 1y agoNeat feature to make use of Containers. I'm thinking of wrapping my video renderer in Containers and use sandbox to spawn the rendering job, but I'm not sure about the limitation of CF containers, such as how much vCPUs I have, how many capability I can get from containers (like SYS_NICE), how many RAM I have and how many jobs I can run at the same time, is there any built-in queue like Runpod (which I am using) to ratelimit the job, etc. I will give this a try.