<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-AU link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>And now I try again today with re-using the connection and the performance is amazing and the CPU usage is much higher than 3% but nowhere near 100%. Looks like I must’ve just been misusing the ZOOM library perhaps..<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><p class=MsoNormal><span style='color:#1F497D'>David Cook<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Systems Librarian<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Prosentient Systems<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>72/330 Wattle St<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Ultimo, NSW 2007<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Australia<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Office: 02 9212 0899<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Direct: 02 8005 0595<o:p></o:p></span></p></div><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US>From:</span></b><span lang=EN-US> David Cook [mailto:dcook@prosentient.com.au] <br><b>Sent:</b> Monday, 17 December 2018 6:07 PM<br><b>To:</b> 'koha-devel@lists.koha-community.org' <koha-devel@lists.koha-community.org><br><b>Subject:</b> Low Zebra performance for persistent/re-used connections<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi all,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’m writing a custom script that uses C4::Context->Zconn to create a Zebra connection and then I’m sending a bunch of queries. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>If I don’t have the GATEWAY_INTERFACE environmental variable defined, that method returns the same connection. (Note that I’m working with Unix sockets and not TCP sockets.)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>When re-using the same connection, my script uses 100% CPU. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>When using new connections for every request, my script uses 3% CPU.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>When re-using the same connection, Zebra seems pretty fast for the first 1000-2000 queries (I didn’t capture exact numbers), but performance degrades rapidly. Around 3000 queries, Zebra is only processing about 4-6 queries per second.  <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>When using new connections, Zebra is handling about 93 queries per second.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Zebra is forking a process for every connection, so it seems like the overhead should be greater creating a new process for every request, but performance is exponentially better when forcing new connections for each request  than when re-using the connection.  <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>It looks like Zebra doesn’t expect a single connection/worker process to handle too many requests. Or maybe it’s an issue with the ZOOM library. I don’t know. I don’t know enough about the internals of either of them. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>So this could affect any command line tool that handles high volumes of Zebra queries. While re-using connections makes sense in theory, it seems to actually cause problems when talking to Zebra. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>David Cook<o:p></o:p></p><p class=MsoNormal>Systems Librarian<o:p></o:p></p><p class=MsoNormal>Prosentient Systems<o:p></o:p></p><p class=MsoNormal>72/330 Wattle St<o:p></o:p></p><p class=MsoNormal>Ultimo, NSW 2007<o:p></o:p></p><p class=MsoNormal>Australia<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Office: 02 9212 0899<o:p></o:p></p><p class=MsoNormal>Direct: 02 8005 0595<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>