|
"I can do a million connections/processes per machine, and that would be very unfeasible with Apache." It's somewhat less infeasible now than it was in the early 2000s. The main barriers to C1M with an OS process per connection are: 1. Stack size. With 8M stacks 1M processes would take up 8 TB of RAM. 2. Process creation overhead - loading the executable into memory, setting up global context, opening sockets. 3. Context-switching overhead: swapping page tables, TLB flushes, saving registers, etc. For #1, recent versions of Linux will happily let you create threads or processes with 4K stacks now. They also don't actually allocate the memory for the whole process, they just map pages, and then the page fault is what assigns a physical page to a virtual address, so if you never touch a memory location it doesn't exist in RAM. For #2, new processes get COWed from their parent and can inherit file descriptors as well, so all the read-only data (executables, static data, MMapped files, etc.) is essentially free. #3 is a legitimate reason why language-based solutions are faster (they don't have to flush the whole TLB on context-switch, and know exactly which registers they're using), but mostly affects speed rather than concurrent connections. |