Cover V10, I07

jul2001.tar


How To Determine Which Network Programming Architecture Is Being Used

Most program documentation remains vague about which network programming architecture is used. Since the architecture is the single strongest determinant of performance under load, you need a way to find out. Below are techniques you can use snoop on an application, even if you do not have access to the source code. First, you must set up a load-creating situation, with at least 200 simultaneous tasks. Then, examine how the process is running with various tools:

Linux

  • Run top
  • One-process-per-task -- Many processes running, all with a different amount of memory use.
  • One-thread-per-task -- Many processes running, all with the same amount of memory use, and the number of processes changes over time.
  • One-thread-many-tasks (one thread) -- A single process running.
  • One-thread-many-tasks (several threads) -- Many processes running, all with the same amount of memory use, and the number of processes is less than 100.
Solaris

  • Run ps -efL. The "NLWP" column indicates how many "lightweight processes" are running inside each process, and lists each LWP in a separate row.
  • One-process-per-task -- ps -efL reports multiple copies of your application, but each has a different process ID, then the application uses the process-per-task approach.
  • One-thread-per-task -- Multiple processes reported by ps -efL for your application. If all have the same process ID, and the number of copies changes over time, then the application uses the one-thread-per-task (multi-threaded) approach.
  • One-thread-many-tasks (one thread) -- A single process reported.
  • One-thread-many-tasks (several threads) -- Multiple copies of your application reported by ps - efL, all running copies of your application have the same process ID, and the number of copies is less than 100.
Windows 2000 and NT

  • Use Task Manager to view active tasks and perfmon.exe to view the number of threads in the running task.
  • One-process-per-task -- Task Manager shows approximately one process per running task.
  • One-thread-per-task -- perfmon.exe shows approximately one thread per running task.
  • One-thread-many-tasks (one thread) -- One process, one thread.
  • One-thread-many-tasks (several threads) -- Task Manager shows one process; perfmon.exe shows less than 100 threads.
Alternative Snooping Technique: Trace the System Calls

  • Use strace (on Linux) or truss (on Solaris and FreeBSD) to display the application's system calls.
  • grep for calls to "select" or "poll", which usually indicate asynchronous operations. Poll() is more efficient than select() with large numbers of connections.
  • grep for calls that start with aio (which stands for Asynchronous I/O) or lio (List I/O). These calls are a likely sign of a sophisticated asynchronous architecture. Examples: aio_write(), aio_read(), lio_listio().
  • grep for calls that start with "pthread" or "thr_" (on Solaris), which indicates some amount of multi-threading. If a new task always causes a call the pthread_create(), then the "one-thread-per-task" design is being used.