måndag 15 februari 2010

Pools and Cache

This weekend I implemented a connection pool for the Plankton Webserver. I let a fixed number of threads start in the initialization and then leave them waiting for clients. Before I started a new connection thread whenever a client connected. This should be better for performance (not that it matters by now, but why not build it in from the start).

Before that I implemented a cache collection object. When a client requests a page, the connection will request it from the cache. If it's not in there, the cache will read it from file and save it in the collection. At this point all pages are kept in the cache, so that files would only have to be read once by the server. I will extend the cache functionality in the future though, calculating popularity, setting a max size etc.

Next i will build a special cache object for .plk pages. This object will keep the file content split up in a collection of WebParts, where the static content will be a new subclass of WebPart called StaticWebPart. This will minimize startup time for a new .plk page, because the page in the cache will already be parsed and ready for the load-method, the triggered event (if any) and the the rendering of the webparts collection.