Thursday, November 10th, 2005
Most of the Ajax world is focused on the client side, and “ooooh ahhhh” effects :)
Greg Wilkins is sitting on the other side of the fence, thinking about the implications of a popular Ajax application on the server side.
Earlier, Greg described how Jetty 6 uses Continuations and javax.nio to limit the number of threads required to service Ajax traffic.
This time around he moves beyond threads, and talks about buffers.
- Operating Systems & Connections: Choose your TCP/IP stack wisely remember when you used to buy a TCP/IP stack? :)
- Connection Buffers: Significant memory can be consumed if a buffer is allocated per connection. Memory cannot be saved by shrinking the buffer size, which is a good reason to have significantly large buffers.
- Split Buffers: Jetty 6 uses a split buffer architecture and dynamic buffer allocation. An idle connection will have no buffer allocated to it, but once a request arrives an small header buffer is allocated. Most requests have no content, so often this is the only buffer required for the request. If the request has a little content, then the header buffer is used for that content as well. Only if the header received indicates that the request content is too large for the header buffer, is an additional larger receive buffer is allocated.
- Gather writes: Because the response header and response content are held in different buffers, gather writes are used to combine the header and response into a single write to the operating system. As efficient direct buffers are used, no additional data copying is needed to combine header and response into a single packet.
- Direct File Buffers: Of course there will always be content larger than the buffers allocated, but if the content is large then it is highly desirable to completely avoid copying the data to a buffer. For very large static content, Jetty 6 supports the use of mapped file buffers, which can be directly passed to the gather write with the header buffer for the ultimate in java io speed.
Great to hear from the server side folk like Greg of Jetty on implications like this.
What implications have you come across?
Have you tweaked your server settings a lot to get that extra bit of performance out of the server side of your ajax app?
Posted by Dion Almaer at 5:16 pm