2

In Flask you can run a "webserver". Well really it's a "WSGI Server". Well really you shouldn't be using core server features like serving files through HTTP at all, you should be using a "real web server" like Apache. That has load balancing, multithreading, etc. In Node.js you can use Express as a webserver. Actually it isn't a server it's a minimalist web framework. You can serve static files through it using static middleware.

I'm feeling pretty confused about all this, I thought I knew what a server does, but now I'm not so sure. I think this is the distinction between an Application Server and a Web Server, but really, even though something like Flask is meant to be an "application server", it clearly does everything a webserver does.

When is something a "web server" and when is it not? In my head, a web server is just something that can handle HTTP requests. Is it incorrect to call frameworks like express and flask servers?

1
  • 2
    Express is technically a web server framework. The actual http server code that it uses is built into nodejs (in the http/https modules). Express adds functionality on top of that existing server code to help you manage incoming requests and produce responses. It's not uncommon, though, for people to refer to an Express server which really just means an http server using the Express framework.
    – jfriend00
    Nov 22, 2023 at 19:25

1 Answer 1

8

In IT in general we're all really bad at using words that are either

  1. Not rigorously defined
  2. The rigorous definition is different than the way the term is commonly used (e.g. strong typing)

In other words, your confusion is normal.

In my head, a web server is just something that can handle HTTP requests

This is correct, or at least correct enough.

In Flask you can run a "webserver". Well really it's a "WSGI Server".

Apache too is (or at least can be with the right add ons) a "WSGI server". WSGI is a protocol, and "WSGI server" and "web server" are not mutually exclusive, the former is a subset of the latter.

You should be using a "real web server" like Apache

Hmmm, let's take a look at the list of criteria you supplied for a "real web server":

  1. Load balancing
  2. Multithreading

I think here, based on those criteria, what the originator of that statement meant by "real web server" is clearly a production-ready web server. The Flask dev server is a real web server: you can make HTTP requests and by golly it responds: static assets, REST calls, you name it. But it doesn't scale to 1e3+ requests/sec, in no small part because it's lacking the criteria you supplied.

To give a further example that (glancing at your profile) may be more in your wheelhouse, is a Microsoft Access database a "real database"? I mean in one sense it clearly is, it stores data, you can query it, etc. But it has severe limitations and if you're the solution architect probably wouldn't be the first thing you'd reach for if you were spinning up a new project that needed persistence.

For the Node.js example, as Jfriend00 points out, the actual web server is provided by the Node.js core runtime and the "frameworks" on top of it mostly provide more convenient ways to stitch code together to serve requests. So is it misleading to call them "web servers"? I dunno. Consider a barge. It's a barge. It floats. It's flat. Say I build a cabin on top of the barge. If I refer to that structure as "my barge" even though the actual barge is just the foundation (N.B. not nearly as useful by itself) is that wrong? Say I say something like "do you want to stay with me on my barge for the weekend?"

Maybe that analogy doesn't hold, and maybe the reference to an "Express web server" is just needlessly confusing, but if you squint at it...¯_(ツ)_/¯?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.