Live data from Hacker News

The appeal of serving your web pages with a single process

utcc.utoronto.ca

41–50 of 63 posts

Re: The appeal of serving your web pages with a single process

#41
post #3

Wholly agree. Too often we think about scale far too early. I've seen very simple services get bogged down in needing to be "scalable" so they're built so they can be spun up or torn down easily. Then a load balancer is needed. Then an orchestration layer is needed so let's add Kubernetes. Then a shared state cache is needed so let's deploy Redis. Then we need some sort of networking layer so let's add a VPC. That's…

I don't think you're agreeing to what the article is saying.

The article seems to be saying, instead of using CGI which spawns a process per request, to have a single Web server binary in Go/whatever. Which is totally reasonable and per my understanding what everyone already does nowadays (are any greenfield projects still using CGI?)

CGI is a "clever 'Unixy' hack" to add dynamicism to early web servers. They stopped being "relevant" a long time ago IMO.

In fact, I think your diatribe actually contradicts the article.

Basically, the article is saying that they went with the "simple" CGI approach which ended up creating more complexity than using the slightly more complex dedicated binary. The author essentially followed your advice which ended up causing more complexity and hacks.

The morale of the story is, you need to use the right tool for the job, and know when to switch. Sometimes that is the simple path, sometimes that is not.

Re: The appeal of serving your web pages with a single process

#42
post #32

Earlier quoted context omitted.

Also, I think people vastly overestimate how much uptime their application really needs and vastly underestimate how reliable a single VPS can be. I currently have VPSes running on both lowend and big cloud providers that have been running for years with no downtime except when it restarts for updates.

> no downtime except when it restarts for updates. This sounds a little like saying "all of North America except the U.S." I don't think people are worried about random breakdowns on a single VPS, but scheduled updates are still downtime, and downtime causes revenue loss regardless of why it happened. Any time a service is important enough I ask for two servers and a load balancer specifically to handle deployments a…

> upgrade windows

Ok, that explains this and the above comment. The last time I had to restart anything to apply an OS update was when I moved to a new RHEL LTS version, the lifespan of which is about 10 years. And there are many ways to do similar GNU/Linux upgrades without a restart at all.

Does Windows Server really need to restart for updates like normal Windows? If so, that's hilariously crap and I'm glad I've never had to touch it.

Edit: not saying a single VPS is fine if it's GNU/Linux, just remaking on the "restart to update" thing they mentioned

Re: The appeal of serving your web pages with a single process

#43
post #28

what was that superfast web server, opensource of some sort, from about 25 years ago, single process, single thread? it just raced around a loop taking care of many queued i/o streams

Perhaps it's quark?

https://tools.suckless.org/quark/

Re: The appeal of serving your web pages with a single process

#44
I was shat on multiple times by throbbing-brain architecture guys for this, but what I've done multiple times that worked in prod, was to start with a single monolith with dependency injection, and run all services in the same process.

Once the compute and robustness demands mandated we should scale the thing across multiple machines, both horizontally and vertically, I would replace most DI services with proxies that wrapped the original functionality and called out to a remote host.

So for this scaled up version, I would only need to change how the DI container got started, which could either be in 'Manager' mode (meaning a high level functionality, with the submodules injected as proxies calling out to services on client machines), 'Worker' mode (meaning it served the proxy requests on said worker machines) or 'Standalone' mode (meaning the DI container actually injected the actual fat versions of the services, that allowed the whole thing to run in a single process, very useful for local testing and debugging).

The was only a single executable which could be run in multiple 'modes' selected via a command line switch, which made versioning and deployment trivial.

Re: The appeal of serving your web pages with a single process

#45
post #3

Wholly agree. Too often we think about scale far too early. I've seen very simple services get bogged down in needing to be "scalable" so they're built so they can be spun up or torn down easily. Then a load balancer is needed. Then an orchestration layer is needed so let's add Kubernetes. Then a shared state cache is needed so let's deploy Redis. Then we need some sort of networking layer so let's add a VPC. That's…

In a former job, I wrote a static PWA to do initial provisioning for robots. A tech would load the page, generate a QR code, and put it in front of the camera to program the robot. When I looked into having this static page hosted on internal infra, it would have also needed minimum two dedicated oncalls, terraform, LB, containerization, security reviews, SLAs, etc. I gave up after the second planning meeting and put…

I am reminded of “I forgot how to count that low”

https://news.ycombinator.com/item?id=28988281

Re: The appeal of serving your web pages with a single process

#46
post #32

Earlier quoted context omitted.

> no downtime except when it restarts for updates. This sounds a little like saying "all of North America except the U.S." I don't think people are worried about random breakdowns on a single VPS, but scheduled updates are still downtime, and downtime causes revenue loss regardless of why it happened. Any time a service is important enough I ask for two servers and a load balancer specifically to handle deployments a…

> upgrade windows Ok, that explains this and the above comment. The last time I had to restart anything to apply an OS update was when I moved to a new RHEL LTS version, the lifespan of which is about 10 years. And there are many ways to do similar GNU/Linux upgrades without a restart at all. Does Windows Server really need to restart for updates like normal Windows? If so, that's hilariously crap and I'm glad I've n…

> to handle deployments and upgrade windows transparently

GP might have meant "upgrade: Windows(tm)", or he might have meant "windows of time which we have allocated to upgrading the server", and on my first reading I interpreted the second without a single shred of thought towards the possibility of the first.

Re: The appeal of serving your web pages with a single process

#47
post #38
post #35

All that's old is new again. More than a decade ago, I inherited a Node application and was able to use many of these exact techniques inside the application. Even moreso, I could introspect the entire application state, including providing myself a shell and modify application state within the application. Keeping a blocklist inside a simple array- no problem! And being able to run a shell inside the same process me…

You can migrate to the heavier infra later. I am serving hundreds of concurrent users from a single Rust binary backed by Sqlite. So far it hasn't shown the slightest problems and migration can happen if the service grows an order of magnitude (or two) from here.

Migration/upgrades need to happen no matter the size of the service, so I'm not sure what you mean.

Re: The appeal of serving your web pages with a single process

#48

Earlier quoted context omitted.

In a former job, I wrote a static PWA to do initial provisioning for robots. A tech would load the page, generate a QR code, and put it in front of the camera to program the robot. When I looked into having this static page hosted on internal infra, it would have also needed minimum two dedicated oncalls, terraform, LB, containerization, security reviews, SLAs, etc. I gave up after the second planning meeting and put…

> When I looked into having this static page hosted on internal infra, it would have also needed minimum two dedicated oncalls, terraform, LB, containerization, security reviews, SLAs, etc. In my experience there are two kinds of infrastructure or platform teams: 1) The friendly team trying to help everyone get things done with reasonable tradeoffs appropriate for the situation 2) The team who thinks their job is to…

I've observed the same and, anecdotally, how much of a pain the ops team is is a function of how much responsibility shifts from the dev team to the ops team during the project lifecycle.

Basically, is the ops team there to support the developer/development team, or the product?

In the case of the development team, the ops team will tend to be willing to provide advice and suggestions but be flexible on tooling and implementation. In the case of the product, the ops team will tend to be a lot more rigid and inflexible.

This plays out in things like:

When the PWA becomes critical for the production line and then "is not working" at 3AM, who is getting paged? If it's the developer, then ops is "supporting the developer". If it's the ops team getting called to debug and fix some project they've never laid eyes on before at 3AM, then it's the product. They are, naturally, going to start caring a lot more about how it is set up, deployed, and supported because nobody likes getting woken for work at 3AM.

When some project's dependencies start running past EOL, who is going to update it? If it's the developer, then ops is "supporting the developer". If the ops team isn't empowered to give a deadline and have _someone else_ responsible for keeping the project functioning, then they're supporting the product and by letting it be deployed effectively committed to maintaining it in perpetuity and they're going to start caring a lot more about what sort of languages, frameworks, etc are used and specifically how projects are set up because context switching to one of dozens of different projects at 3AM is hard enough as-is without having to also be trying to learn some new framework du jour.

(And before anyone says "well the updates probably aren't necessary this is just ops being a pain"--think of the case of a project relying on GCP product that's being shutdown or some kubernetes resource that's been changed. In one case inaction will cause the project to fail, in the other ops' action will cause it to fail. See the first point as to who is going to get called about that. Even in the happy case, consistency brings automation and allows the team to support a _class_ of deployments instead of individual products.)

I don't think places exist stably in the middle ground because it's a painful place to be for very long. The responsibility and the control land on separate people, and the person with the responsibility but without the control is generally going to work to wrestle control to reduce misery. In the case where ops acts as if they're supporting the developers but is in practice supporting the product, it's not going to take too many 3AM calls before they start pushing back on how the product's deployed and supported.

I've been both of those ops guys you describe. When I was the "checklists, meetings, and picking the project apart" guy it had nothing to do with me wanting to make anyone's life difficult or flexing my knowledge. It had to do with the 3AM calls waking myself, my wife, and my newborn up. If I was taking on responsibility for keeping your _product_ functional through its useful life, yeah, I wasn't going to let people dump stuff on my plate unless I had some reasonable basis to believe it wasn't going to substantially increase my workload and result in more middle of the night calls. The checklists were my way of trying to provide consistency and visibility into the process of reducing my own pain, not my way of trying to create pain for others.

Re: The appeal of serving your web pages with a single process

#49

I guess it depends on what world you live in. For example, using ASPNET Core, I just drop in this https://learn.microsoft.com/en-us/aspnet/core/performance/ra... and boom I have rate limiting and I do not have to stress about threads or state or whatever.

That's rate limiting locally i.e single instance. It is a fairly trivial thing and isn't the topic here.

While that is true, at that point you should be rate limiting at the reverse proxy or load balancer.

- Nginx https://blog.nginx.org/blog/rate-limiting-nginx

- Caddy https://github.com/mholt/caddy-ratelimit

- Treafik https://doc.traefik.io/traefik/middlewares/http/ratelimit/

Re: The appeal of serving your web pages with a single process

#50
post #30

I guess it depends on what world you live in. For example, using ASPNET Core, I just drop in this https://learn.microsoft.com/en-us/aspnet/core/performance/ra... and boom I have rate limiting and I do not have to stress about threads or state or whatever.

That's almost certainly per server instance though, there's no mention of any type of synchronization across multiple instances, so if you e.g run many small ones or run the service as a lambda I'd be surprised if it worked like you expected.

At that point you should be rate limiting at the reverse proxy or load balancer.

- Nginx https://blog.nginx.org/blog/rate-limiting-nginx

- Caddy https://github.com/mholt/caddy-ratelimit

- Treafik https://doc.traefik.io/traefik/middlewares/http/ratelimit/

IMO Lambda is kind of an unfair example because the author doesn't mention having multiple instances. Plus a hot take I have is you should not be building an entire web-app as a Lambda or series of Lambda functions... AWS does not have solutions for load balancing in things like APIG so you would have to architect that via DynamoDB or ElastiCache which is the "extra layer or two of overhead" the author mentioned.

Post reply on HN