Re: threads or processes?
Re: threads or processes?
- Subject: Re: threads or processes?
- From: Kaelin Colclasure <email@hidden>
- Date: Sat, 28 Jan 2006 09:05:28 -0800
On Jan 28, 2006, at 8:25 AM, John Stiles wrote:
Andrew Farmer wrote:
On 28 Jan 06, at 00:55, Andrew Bush wrote:
Im looking at writing an app that will be required to have a
number of connections to a remote server going at once, up to
100-200.
Im wondering whether the best design in mac os x would be to use
multiple processes...spawn one process for each server and let
them do their thing...or whether I would get better performance
by handling with them all in one process.
Use a single process. Cocoa will let you add a socket to a
process's runloop, so you don't even have to do anything fancy to
wait on input. If that doesn't work, then go with threads.
Creating a process for each connection is (1) total overkill and
(2) will hit the standard per-user ulimit of 100 processes.
In OS X? Are you sure?
MafiaHQ:~ jstiles$ ulimit
unlimited
At any rate, I agree that one process per connection is expensive.
However, it's what Apache used to do IIRC (and maybe still does, I
don't know), so it can't be /that/ awful.
While there are (debatably) several advantages to Apache's multi-
process server architecture, recall that Apache was designed for
portability in an era when many Unix systems did not have OS threads.
And the OP implies a client implementation. The trade-offs are
usually biased differently when implementing a client vs. a server.
In general I would echo Andrew Bush's recommendations. Use a runloop,
or threads if you must.
-- Kaelin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden