7

How is Apache in respect to handling the c10k problem under normal conditions ? Say while running very small scripts with little data, or do I need to scale out if I use Apache?

In the background heavy lifting is done by a few servers running specialized software that processes the requests but I'd like to use Apache as a front. Is this a viable plan?

Sean Bright
  • 118,630
  • 17
  • 138
  • 146
Robert Gould
  • 68,773
  • 61
  • 187
  • 272

3 Answers3

9

I consider Apache to be more of an origin server - running something like mod_php or mod_perl to generate the content and being smart about routing to the appropriate system.

If you are getting thousands of concurrent hits to the front of your site, with a mix of types of data (static and dynamic) being returned, you may find it useful to put a more optimised system in front of it though.

The classic post-optimisation problem with Apache isn't generating the dynamic content (or at least, that can be optimised for early in the process), but simply waiting for a slow client to be able to receive the bytes that are being sent. It can therefore be a significant advantage to put a reverse proxy, in the form of Squid or Nginx, in front of the servers to take over the 'spoon-feeding' of the slow network clients, while allowing the content production to happen at full speed, and at local network speeds - 100Mb/sec or even gigabit speeds - if it even has to traverse a network at all.

Alister Bulman
  • 34,482
  • 9
  • 71
  • 110
2

I'm assuming you've probably seen this data, but if not, it might give you some idea.

MarkusQ
  • 21,814
  • 3
  • 56
  • 68
  • 1
    Good information, and I like thttpd a lot (I've used it a couple of times in the last 8 years). Important to note though, that the table of info you list is more than ten years old. – Alister Bulman Nov 10 '09 at 18:19
  • 1
    That page says "last updated in 1998" ... has anyone done any similar banchmarks since then? – Dobes Vandermeer Mar 24 '12 at 13:26
1

Guys, imagine that you are running web server with 10K connections (simultaneous). How could it be?

  • You've got many many connections per second

    • Dynamic content

      Are you sure that your CPU can handle that many PHP sessions for example? I guess no, so why are you thinking about C10K problem? :D

    • Static content - small files

      And still soo many connections? On single server? Probably you've got problems with networking/throughput too or you are future competitor of Google. Use lighttpd which addresses C10K problem and is stable - fly light. Using Apache for only static files for large sites is obvious.

  • Your clients are downloading large files for a large time - static content

    • ISO images, archives etc

      If you are doing it via web server - FTP may be more appropriate.

    • Video streaming

      Use lighttpd or specialized software. And still... What about other resources?

I am using Linux Virtual Server as load balancer in front of apache servers (with specific patches for LVS-NAT) and I am happy :) This string is an answer you want to hear.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
GioMac
  • 190
  • 2
  • 9
  • 1
    you might want to tone down the language a bit - that tends to attract flags etc. And an automatically-deleted answer doeesn't help the OP or do justice to your time in answering it. – Marc Gravell May 26 '11 at 12:23
  • use low tcp and keepalive timeout values and you will not have this problem. anyway, you will have same problem on other servers, before packets will reach it :) – GioMac Oct 25 '12 at 14:36