Improve JSON Server Performance (patch to follow)

Steven Merrill - July 30, 2008 - 16:21
Project:JSON server
Version:5.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Steven Merrill
Status:needs review
Description

In using JSON Server on bobdylan.com, we noticed two performance boosting tweaks:

1) Use json_encode() if it's available. (This produced a decent speedup.)
2) Use GZIP encoding if the client supports it (This gave us a GIANT performance boost.)

I need to re-roll the code into a patch, but #2 helped speed up the site a GREAT deal. I'll try to send it along in a week or so.

#1

Steven Merrill - July 30, 2008 - 16:23

My reasoning for using json_encode() if available is as a speed boost (since it's baked-in,) and also by virtue of the fact that HTML escaping does not seem to be needed in drupal_to_js() any more - see http://drupal.org/node/222578#comment-773458.

#2

andremolnar - August 6, 2008 - 21:42

Furthermore the escaping done results in invalid json being returned. I'll be happy to review your patch when it lands. Internally we've already made a similar change in some of our own json generation (unrelated to our services)

#3

kehan - September 16, 2008 - 15:55

subscribing

#4

Steven Merrill - October 29, 2008 - 17:40
Status:active» needs review

Hey - look - a patch!

It's against CVS HEAD as of today. It will use json_encode if available, and GZIP compression if the client supports it. This helped boost performance quite a bit on BobDylan.com.

Enjoy!

AttachmentSize
json_server_gzip_performance.patch 2.7 KB
 
 

Drupal is a registered trademark of Dries Buytaert.