Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Comment on

( #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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (5)
    As of 2014-08-23 09:52 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (173 votes), past polls