162 points · by tylerhou · 8y ago · 91 comments
But doesn't that mean we are merely reimplementing old concepts on a new level? Almost everything we do on VM level we already did on process level:
- Read-only VM images are essentially like statically linked binaries, just better encapsulated when they run.
- Tiny, fast loading VM images are essentially stripped static binaries with dead code elimination.
- Starting those by incoming network request is just like old "inetd" versions started custom handler programs on each request.
- Same with CGI, just on HTTP rather than TCP level.
- Manual maintaining the lifecycle of those VMs like FastCGI in nginx.
- Maintaining the lifecycle of such a started VM is essentially like FastCGI in Apache (or nginx + auto-spawner).
The only real difference is the improved encapsulation (controlled network access and resource consumption) of the running code, isn't it?
What might come next?
- Multiple VMs could share the same images to save memory, essentially reinventing shared libraries and dynamic linking.
- Network traffic into and out of a VM is controlled more tightly, reinventing SELinux. (Perhaps followed by noticing that these profiles are hard to maintain, rediscovering the maintenance issues of SELinux systems.)
- Providing the network traffic shape directly with the image, so these can be maintained at a single place, by the original developers. This would reinvent Pledge.
- Introducing permissions for network traffic, e.g. such that just one group of application VMs can communicate with the database VMs. Ideally with an ACL system as used for managing file permissions. This would reinvent Unix Sockets.
It would be more interesting if we just made more sandboxing powers available for traditional processes, though there is already quite a lot of sandboxing available for Linux processes...
CGI starts a process per request. fastCGI can reuse processes. Problem already found and solved 20 years ago.
catern@home ~ $ { timeout 1 sh -c 'while :; do /bin/echo foo; done'; echo; } | wc -l
1542
So at least sub-millisecond. And this is less efficient than possible because it's also writing to a pipe.Also, I quite agree that CGI is a bad way to do things, but that's what the original post is proposing. :)
You just described containers :)
Most of that is not really necessary if you are just coming from a standpoint of "I want to sandbox a process". Indeed, if you just want to sandbox a process, just run it under a dedicated non-root user account, and it won't be able to unduly interfere with the rest of the system.
We'll just keep building layers as manufacturers try to lock the lower ones down :)
See WeChat in China for a good example on Android
Basically, the cost of spinning VMs is coming down drastically (with Hyper.sh and Intel ClearContainers offering 200ms boot) and it is now feasible to run your apps on a personal cloud sandbox. You data resides in that box and runs code you have approved; away from the prying eyes of FB, Google and the government. Everyone's facebook will be an individually hosted app, talking to each other over agreed upon protocols; as opposed to exchanging data within the facebook infra.
Of course, a lot of UX and engineering problems need to be solved along the way. Provisioning a personal sandbox cannot be any harder than creating an account on a Social Network. Beiber's sandbox will need to distribute data to 105M followers efficiently. You'll need to patch vulnerabilities at scale, so there needs to be some trust model for applying patches. You need relays to overcome censorship etc.
I tried to solve this problem using derivative regular expressions as graph queries
paper: http://onlinelibrary.wiley.com/doi/10.1002/spe.2226/abstract
source code: https://github.com/amitport/graphpack
(there are other solutions, I admit this is just a plug, but it will be great if it could gain traction)
The main issue just now is that writing (or deploying) IndieWeb platforms and hosting them is the preserve of geeks, and it will not take off and displace current platforms until we can make it trivial for Mom and Dad to join us.
Unsurprisingly, it is not used by “normal” non-techy people.
Now that I think of it, spiders/bots might activate it beforehand. You could use robots.txt, but not all spiders/bots seem to follow those "rules".
Food for thought!
Sidenote: some customers might use monitoring :)
However, is there a point in shutting down the VM right away, other than being a cool demo? It seems to me that you could quite easily keep it around if there are more requests queued, and quickly spawn more workers if the queue gets too long. So a regular worker pool, just that the number of workers can be adjusted relatively quickly.
Whether that'll be worth the cost remains to be seen - 250ms is still far too long for most uses, but if it can come down enough, it's attractive.
Also worth noting I wrote a bunch of benchmarking tools to help optimize this case[2].
[1] http://oirase.annexia.org/tmp/paper.pdf
[2] https://github.com/libguestfs/libguestfs/tree/master/utils
I really hope this can be pushed further down to the point where it gets viable to for more use cases. Of course, we can always use something lighter than Linux, but being able to start with Linux and pare down is potentially so much easier for many types of applications.
Isn't this just cgi-bin, right down to the long startup time and lack of persistence?
But you can reach comparable levels of isolation with processes: just use Linux namespaces.
Slightly off-topic: the page lists be time for an android phone to boot as 50 seconds. Is that correct? I remember iPhones used to take forever but I recently realized that they sing to boot extremely fast. I have no idea when that change happened.
Actually I had to do it twice because the first time it installed a system update, but even then it only took 26 seconds to install, finish booting, and show the lock screen. System updates have been seriously optimized in the last few Android releases. They used to take like 5 minutes.
On the Pixel phones Google uses two system partitions. One is the one you're currently running and the other one gets the update applied to it in the background without you having to stop using your phone. When you reboot it just has to flip which system partition it boots from and maybe do some first boot actions. If the phone starts up successfully it'll then apply the update to the original partition to keep them in sync.
My iPhone 8 was 20s to login screen. It basically instant once I login but that may be because my password takes a while to type and it’s loading the rest while I type.
So I tried rebooting with all of my apps exited. 25 seconds.
Actually slower than I thought. I found an old blog post that says an iPhone 5 took about 35s, the slowest of the models they tested.
2x is nice but maybe it didn’t improve as much as I had thought.
https://www.ifixyouri.com/blog/iphone-6s-bootup-time-compari...
I’m sure it’s technically more secure than a sandboxed application running in its own VM in its own process but by how much?
So to recap instead of the typical stack of:
Erlang Code | BEAM VM | Linux or other OS | VM or Hardware
You get: Erlang Code | Ling | Xen | Hardware
The use cases could be isolation, scaling or what authors calls 0-footprint cloud. That is, only spawn instances as you process requests. When requests are not coming, you don't have any instances running. In more modern terms maybe it could be used for building a serverless architecture used to run cloud "functions"Yes there is obvious irony here with the demo not handling requests well after the HN frontage hug of death, but I think it is still a beta / experimental product, it has been around for a good number of years and is somewhat abandoned. If anyone knows more please feel free to correct me.
I know loading JVM based applications have horrific startup times on cold boot, but I was just wondering could you run the JVM directly on top of Xen?
Given that this was written roughly 4 years ago (guessing by some dates on the site), its not clear what their support looks like for newer features like maps might be.
Performance looks good (relative to BEAM) but they are also single-threaded which means you'd need to cluster your instances to do multi-processing... and I'm not sure that'd mix well with ephemeral nodes. They talk a little more about this on their site: http://erlangonxen.org/more/clustering
http://www.skjegstad.com/blog/2015/03/25/mirageos-vm-per-url...
Is it considered "stable" or is it simply abandoned? Are there any successors? Near zero overhead VM acting on data storage is something I'll need for a planned project of my own.
I'm thinking of building something here for static sites as an open source project/spec. If anyone is interested in bouncing ideas on this, please ping me via email (in profile).
(it would no longer be strictly static, but the idea is to decouple site from hosting/compute, so it would be easy to port a static/dynamic site between providers at the switch of a DNS entry).
> The demo is limited to 16 concurrent instances and 2 libvirt connections. Due to these limitations we were unable to spawn a new instance to service your request. Please try again later.
Kool.
If your VMs are truly cheap, and you've ironed out the kinks from your proof-of-concept, you'd obviously set up your production system to run more than 16 of them.
Obviously no one would ever run something like this 1 vm per request thing irl.
I can see plenty of use-cases for doing just that. Large uploads, time-consuming request/responses such as server-side data processing, RPC, as a backend behind a caching front-end so that it only has to respond to invalidated cache entries, etc.
I don't see many people using this to actually serve general website requests though. It'd probably be modified to serve multiple requests until nothing is left to do and then exit.
I see phase A from 126.3 ms to 187ms.
Ah, there’s the rub.