News for hackers. Stuff that matters.
Re:Don't Bet on Moore Saving Your Ass by ars on Wednesday January 07, 2009 @04:33PM (#423992)
I'm starting to understand what you mean.

You have one program, that handles multiple requests in the same program - but it's just one program.

As opposed to multiple programs, each handling one request.

I can see how that will handle any IO issues, and if starting a program has overhead, that will help too, but it still seems like it won't do a good job of keeping the CPU busy.

But you did say earlier that you were not CPU bound. All my websites have been CPU bound (well I think they are CPU bound), so I guess that's why I didn't get it at first.

Re:Don't Bet on Moore Saving Your Ass by axod on Wednesday January 07, 2009 @04:41PM (#424004)
They may well be CPU bound because of context switching.
Re:Don't Bet on Moore Saving Your Ass by abstractbill on Wednesday January 07, 2009 @04:48PM (#424016)
Right. Ars, here are a couple of points you may be missing:

- Adding threads "works" up to some small number (maybe a few hundred or so - depends on your platform). Then adding more threads just takes up more cpu without doing any useful work. Your program can seem cpu-bound, when actually you just have so many threads that none of them can do anything.

- The approach axod and I are talking about uses a single thread to service many network connections. Obviously you have to write your code quite differently to handle this: Your code is typically "triggered" by an event like receiving a few bytes over one network connection. You do a (very!) small amount of work, and then you quickly return control to the network core (called the "reactor" in Python's Twisted library). The core then waits for another event (e.g. more bytes arrive on a different network connection), and the cycle repeats.

Hope that helps.

Re:Don't Bet on Moore Saving Your Ass by ars on Wednesday January 07, 2009 @05:05PM (#424046)
It does, thanks.

I was letting apache do the threads, so under 100 probably.

Thanks for posting this - and staying on the thread. I should probably go back and re-read the thread now that I get what you are saying.