NetProg 2002 HW5 FAQ


Question:

On Solaris using pthreads and gcc, don't we need to compile with -D_REENTRANT so that each thread has it's own copy of errno ?

Answer:

Yes, you do need this on Solaris when using pthreads. You should compile with something like this:

gcc -Wall -o hw5 -D_REENTRANT hw5.c -lsocket -lnsl -lpthread



Question:

Should our server print something out each time it handles a request?

Answer:

No! This will slow down your server and your measurements will be way off. Don't print anything in the server (when everything is working fine).




Question:

There seems to be something wrong with my server that is messing up the entire machine it is running on. If I run ab with thousands of requests and client concurrency of 100 the machine slows to a crawl and my server doesn't seem to be reachable. What's wrong with my server?

Answer:

You are probably overloading the machine, not your server. You are, in fact, generating a SYN attack on the machine hosting your server by telling ab to use such a high concurrency level. I'd suggest using much smaller numbers - we don't have high-end machines hosting our programs so we can't expect them to be able to handle that much of a pounding.

My suggestions: use server concurrency up to 10 or 20, and use client concurrency no more than about twice the server concurrency. Don't go near client concurrency of 100 for very long (very many requests total)!




Question:

Say you pre-fork 10 processes, and then you issue 20 requests, should the server handle the last 10 requests sequentially, or should the server always make sure there are 10 pre-forked processes, so on the 11th request it would fork off 10 more processes. It seems strange to only handle the first 10 requests concurrently and then have everything else handled sequentially.

Answer:

Each of your processes should be an iterative server, so they should be able to handle more than once request.

Since the parent process doesn't have anything to do in this kind of arrangement, you can just fork 9 times and then have the parent also become an iterative server (for a total of 10).




Question:

Do we need to use locking around calls to accept()?

Answer:

No. The version of Solaris on the CS machines does handles calls to accept fine, you do not need to ensure that only one process/thread is calling accept at a time.




Question:

You mentioned in class that we can exit if fork() or pthread_create() returns an error, what is the issue again?

Answer:

In general it is very difficult to recover from these kinds of problems and continue on. The issue is that I don't want people experimenting with ways to recover from a failure to fork() or pthread_create(), since it is easy to generate forking loops (or loops that keep creating or trying to create threads) and this could make the machine unusable for everyone else...




Question:

The ab program seems to connect to my server more times than I expect, even if I only ask for one request it connects more than once, what's up with that?

Answer:

I understand why it happens for concurrency levels greater than one - ab is blasting away at the concurrency level requested until it has completed the desired total number of requests. One it is done it shuts down any remaining connections (keep in mind that ab doesn't know which ones will complete first).

I don't understand why this also seems to happen when the concurrency is set to 1, but it happens (I get 2 connections from ab when I use ab -n 1 -c 1). This should not cause any problem for your server...