Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi Monks,

I have a strange issue and I am not sure if anyone has seen anything similar before. I have a web app running on windows and I am porting it to mod_perl to give it a massive performance boost.

I am all but done, however I am hitting an issue with the JSON module when the service is put under load and it is puzzling me something stupid.

I make quite extensive use of JSON::true and JSON::false in my application, but it seems that under load in mod_perl it can in some cases return null instead of true or false.

I have run a simple script which proves the point I am having. This just creates a simple data structure including a JSON::true and then encodes it and prints the results.

In CGI mode this works fine and in mod_perl it works *most* of the time. When placed under load with apache bench the result of success some times comes out as null when it should say true. This breaks my application and is the only thing that is stopping me going forward with mod_perl. This is the test script I use;

use JSON; my $json = JSON->new(); $json->convert_blessed(1); $json->allow_blessed(1); my $data = { success => JSON::true, test=>'Hello' }; print "Content-type: text/html\n\n"; print $json->encode($data);

This prints out the following all of the time in cgi mode but only some of the time in mod_perl. {"success":true,"test":"Hello"}

An example from Apache Bench shows the following when I have 50 concurrent users requesting 1000 pages.

LOG: header received: HTTP/1.1 200 Date: Fri, 01 Mar 2013 16:09:11 Server: Apache/2.2.23 (Win32) mod_auth_sspi/1.0.5 mod_perl/2.0.7 Perl/ Connection: Content-Type: text/html {"success":true,"test":"Hello"} LOG: header received: HTTP/1.1 200 OK Date: Fri, 01 Mar 2013 16:09:11 GMT Server: Apache/2.2.23 (Win32) mod_auth_sspi/1.0.5 mod_perl/2.0.7 Perl/ +v5.16.1 Connection: close Content-Type: text/html {"success":null,"test":"Hello"} LOG: header received: HTTP/1.1 200 OK Date: Fri, 01 Mar 2013 16:09:11 GMT Server: Apache/2.2.23 (Win32) mod_auth_sspi/1.0.5 mod_perl/2.0.7 Perl/ +v5.16.1 Connection: close Content-Type: text/html {"success":null,"test":"Hello"} LOG: header received: HTTP/1.1 200 OK Date: Fri, 01 Mar 2013 16:09:11 GMT Server: Apache/2.2.23 (Win32) mod_auth_sspi/1.0.5 mod_perl/2.0.7 Perl/ +v5.16.1 Connection: close Content-Type: text/html {"success":null,"test":"Hello"} LOG: header received: HTTP/1.1 200 OK Date: Fri, 01 Mar 2013 16:09:11 GMT Server: Apache/2.2.23 (Win32) mod_auth_sspi/1.0.5 mod_perl/2.0.7 Perl/ +v5.16.1 Connection: close Content-Type: text/html {"success":true,"test":"Hello"} LOG: header received: HTTP/1.1 200 OK Date: Fri, 01 Mar 2013 16:09:11 GMT Server: Apache/2.2.23 (Win32) mod_auth_sspi/1.0.5 mod_perl/2.0.7 Perl/ +v5.16.1 Connection: close Content-Type: text/html {"success":true,"test":"Hello"}

As you can see some times the success value comes back as null and I have no idea why? I can only assume that there is an issue with JSON::XS in one of the threads within apache.

If I remove JSON::XS and use JSON::PP then the issue goes away and all of the bool values come back as expected however there is the big performance hit here so I do not see that as a solution.

I am currently running Apache 2.2.23 with mod_perl 2.0.7 and running ActivePerl v5.16.1. The JSON::XS module installed is the latest which is 2.23 and the JSON core is 2.53 which came with ActivePerl.

Has any one seen this behavior in the past or have any suggestions as to what could be causing this issue?

Many Thanks,
Alistair


In reply to JSON::XS Bool issue in mod_perl by allyc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-03-19 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found