0

What technology could be used for one application to serve many simultaneous users on a small resource-constrained host (eg: Rasbperry Pi or similar)?

That is, it doesn't need a general purpose web server like Apache, as it would only need to support one application and a couple of active web pages, but many connections.

I understand Apache/PHP/MySQL on bigger servers, but those would seem to require too much resources to support many simultaneous (order of 100, say) connections on a small host - with every connection redundantly loading in its own copy of the same interpreted code.

I'm thinking, for example, to skip the general purpose webs server and have one memory resident compiled C++ program which services many concurrent HTTP connections - light weight and fast. The application would be fairly simple. Or perhaps an add-on or module for a lightweight web server. Or maybe something like node.js, if that was very resource efficient and easy to scale even on a small host. I don't even know the terminology or keywords for the style of programming I'm looking for, hence my question.

I tried StackOverflow, which suggested Raspberry Pi exchange, where this exchange was suggested. Any tips or clues?

Zeph
  • 109
  • 2
  • Use a CDN with appropriate caching headers and CDN configuration. Your device generates the pages for each CDN node, then it's static. If the pages require personalisation please edit your question to clarify. – Tim Sep 01 '17 at 06:02

4 Answers4

2

doesn't need a general purpose web server like Apache

Look for a lightweight web server like Mathopd, thttpd, Lighttpd.

one memory resident compiled C++ program which services many concurrent HTTP connections - light weight and fast

"a fast, lightweight, non-forking HTTP server for UNX systems"* in less-than 4K LoC of C -- Mathopd.

many simultaneous (order of 100, say) connections

Apparently

igouy
  • 121
  • 3
1

I think your main choices are node and golang. On the face of it Go would win based on performance, https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=go&lang2=node, however depending on the complexity of the program you are trying to write and the reliability you need node might be efficient enough and it's definitely easier to write a simple program.

I would research both of these options write a simple program and test to see which would suit your use case best.

Peter Grainger
  • 163
  • 1
  • 7
0

If your site is all static, using a CDN will allow you to serve hundreds of thousands of clients on a Raspberry Pi without issues. The CDN will fetch the pages and cache them for you. Only when you change the pages the CDN will have to fetch them again.

If only part of the site is dynamic, you can employ a hybrid approach. Make the site the most static possible, and use Ajax to only retrieve the changed data. Retrieving only a small json with user data uses less resources than retrieving an entire HTML page. A client side script will fetch the dynamic data, and render the HTML on browser. Have the static part hosted by a CDN.

As others noted, you don't need Apache for a small site on a small device. Besides Mathopd, thttp and lighthttpd, you can try Nginx, Hiawata, Monkey Server, kHTTP Server, libmicrohttpd.

ThoriumBR
  • 5,302
  • 2
  • 24
  • 34
0

Flask is a lightweight Python framework for web development. This might work, depending on what you mean by "many".