Apache2 Config

Hi fam,

I run a website that hosts video, it is extremely basic, but it gets the job done.

The videos are just on a static page inside a <video .> tag.

I don’t really want give out the domain, but it gets about 400 users / day (70-100gb down/day)

Anyway, when a the page is loading, it seems that apache only opens one connection (thread?) to the client for downloading the content of the page (including video). This works fine on fast connections, but if you have a slow internet connection and are located far from the server it can become slow compared to other sites.

Is there an easy way to enable apache to establish multiple connections to the user?

Thanks
~itvara

More information:
Scaleway C1:
Apache/2.4.18
Description: Ubuntu 16.04.2 LTS
200Mbit/s Up/Down

I don’t know if apache spawns multiple threads but what I can tell you is that internally, apache has a queue for users connections. So the more users the large the queue, the slower for people on slow connections.

What you can do to alleviate this is to have a web-socket fetch your content from the database instead, these are asynchronous connections.

As far as this goes, I don’t think you can do this without setting up load balancing across multiple servers.

1 Like

Agree with the load balancing. This may also be helpful.

https://httpd.apache.org/docs/2.4/mod/worker.html

400 users / day … or 400 hits per day.

thread per connection is very wasteful, a modern server will use epoll (or kqueue and friends on non-linux hosts) allowing it to terminate thousands of connections simultaneously all while using very little resources.

https://httpd.apache.org/docs/2.4/mod/event.html is a better option.

This works by asking the kernel to keep an eye on activity across a number of file descriptors representing network sockets. The server code will read “events” describing this activity from yet another file descriptor, and it’ll pass these events to a threadpool for processing. Example of said activity could be, “fd=123 has data for you”, and the threadpool would say, “Aha! fd=123 is in the middle of reading http request headers, get the data available and parse as much as possible, and then move on to next one, aha … fd=80384 has some data … let’s see” … the benefit is that kernel doesn’t have to context switch in order to switch between connections. With a thread per connection model, switching is costly when you have many clients. Also, the server uses less ram as it doesn’t have to maintain a stack per connection.

Have you considered nginx by any chance, it supports a thing called sendfile and another thing it calls aio threads and it allows you to control which files go through pagecache and which ones don’t which is awesome your files don’t fit in ram and are always streamed (e.g. video), because you get to use your ram / page cache for html and css etc.

Is there any specific reason you are using a version of Apache thats almost two years old? 2.4.18 was released in Decembre 2015, while the newest (2.4.27) one was released in July 2017. Installing the newest updates of your webserver should be mandatory.

A quick CVE search yileds six exploits which could be used against this server. (To be honest, I’d have expected more :-D) Unless you’ve disabled the version number in the HTTP header, it is also easy to discover said version, without reading this thread.

I’m sorry I didn’t help you with your problem, though it seems this has been done by others, but this was something I just had to mention.