Monday, May 22, 2006

HTTP Benchmarking

Benchmarking my HTTP server revealed some issues - I was not closing components after their TCP connection closed. Initially I was getting throughput of about 5 hits/sec. After some tweaks, such as only yielding when left with nothing to do, I managed to get 100 hits/sec for highly dynamic pages or 800 hits/sec for small static pages when using persistent connections. This is fairly good, although an simple, efficient webserver written in C could probably handle several thousand hits/sec. I've been using siege to do the load testing/benchmarking.

I found a bug in the Kamaelia TCP components - they raised an exception when the remote host disconnected unexpectedly, taking down the entire HTTP server in the process. :D

I've made a handy little Python script to convert tabbed code to spaced code.

#!/usr/bin/env python
import sys, string

def tabsToSpaces(path):
myfile = open(path, "rb")
contents = myfile.read()
myfile.close()
lines = string.split(contents, "\n")
contents = []
for line in lines:
tabs = 0
replacement = ""
while line[tabs:tabs+1] == "\t":
tabs += 1
replacement += " "
contents.append(replacement + line[tabs:])

contents = string.join(contents, "\n")
myfile = open(path, "wb")
myfile.write(contents)
myfile.close()

if __name__ == "__main__":
if len(sys.argv) != 2:
print "Usage: tabsToSpaces.py "
else:
tabsToSpaces(sys.argv[1])

0 Comments:

Post a Comment

<< Home