Forum Moderators: coopster

Message Too Old, No Replies

Building a LAMP server optimized for downloads

         

httpwebwitch

3:26 am on Apr 6, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey all you intelligent people.
I need to build a server that's hyper-optimized for delivering fast file downloads. Mostly files sourced from external URLs, manipulated and/or renamed and then delivered to the user. Some will be generated on the fly by various microservices. This server will have no databases, no email, no fluff. I do think a local cache will need to exist, but I am worried about the challenge of cache invalidation.

Do you have any advice?

I'm asking in this room because any scripting I do will be in PHP, and frankly we all know that PHP programmers are the smartest. Right?

RonPK

3:35 pm on Apr 7, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not very intelligent, so bear with me... I'd try to optimize the web server. Settings like "AllowOverride none", KeepAlive and KeepAliveTimeout, in case you're using Apache. Some say nginx is faster, so perhaps give that a try?

btw, LAMP without a database isn't LAMP...

phranque

5:24 pm on Apr 7, 2015 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



"Building a LAP server optimized for downloads"

LifeinAsia

5:28 pm on Apr 7, 2015 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



aka a LAP Dance?

httpwebwitch

3:13 am on Apr 9, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK OK I get it it's not actually LAMP if there's no M, possibly no A either.

RonPK

6:50 am on Apr 10, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some suggestions:
  • Use a compiled code cache (like APC), it seriously speeds up PHP applications.
  • Don't use a framework, as it will probably load lots of unused code into memory.
  • Try not to use include or require; just copy the code they import into the main script.
  • Avoid the use of regular expression pattern matching, as it may spike CPU usage.
  • On a micro level: use single quotes to enclose strings. Double qoutes make the parser look for variables in the string.
  • Avoid long loops (duh).

default password

5:36 am on Apr 29, 2015 (gmt 0)

10+ Year Member



I wonder what could be faster than:

<a href="download.zip">download</a> where the file is any binary file.

However, you might what to look into a bit torrent, [en.wikipedia.org...]

brotherhood of LAN

5:51 am on Apr 29, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you're using PHP, strip out all the modules you don't need and it'll reduce the memory footprint per process.

d3vrandom

7:45 pm on May 1, 2015 (gmt 0)

10+ Year Member



If it's static files you want to serve then it's not LAMP that you want but LEMP. That is you use nginx because it is much bette than Apache at static file serving and can do PHP too. You will want to do caching because it makes no sense to hit PHP for static files unless absolutely necessary. You can use nginx fastcgi_cache for this although there are probably better ways to do it if you design your app for it from the very start.