Zope and Large Files

Want to know why Zope sucks at transferring large files, that people have to resort to using Apache? The answer lies in asynchat.

Line 215 of asynchat.py in the fragment below chews up all the CPU cycles. Once I altered that, CPU utilization drops to 30%, and Zope becomes IO bound finally (that’s a good thing).


204     def initiate_send (self):
205         obs = self.ac_out_buffer_size
206         # try to refill the buffer
207         if (len (self.ac_out_buffer) < obs):
208             self.refill_buffer()
209
210         if self.ac_out_buffer and self.connected:
211             # try to send the buffer
212             try:
213                 num_sent = self.send (self.ac_out_buffer[:obs])
214                 if num_sent:
215                     self.ac_out_buffer = self.ac_out_buffer[num_sent:]
216
217             except socket.error, why:
218                 self.handle_error()
219                 return

About this entry