Application Servers


In my last piece about instrumentation I (hopefully) showed the importance of instrumenting your code – in many ways it is one of the major “unwritten� requirements in any project – along with a good logging strategy. The tough question is what do you instrument and what are the options?

As with most things in development there are many options and variants – you just need to choose what feels right for your project. A passionate and professional developer after a few years in the minefield of software development gets to know what will and more importantly what will not work in a situations.

Ninety percent of software development involves something (user/software) invoking a method or command on some target object. Some of the things you can track from that is:

  1. How long the invocation took.

  2. The result of the invocation (success, error etc).

  3. The average time invocation of this method/command.

  4. The maximum time of any invocation.

  5. The minimum time of any invocation.

  6. The invocation/min/max/average times for 1-5 for the last n commands.

  7. Values 1-5 but broken down by success/error etc – can help if “success� times take a lot longer than the errors.

  8. How much memory was used.

  9. How many times method/command has run.

  10. Tallies on errors.

  11. Deviation counters – How many times <1 second, <10 second, <100 sec, <1000 sec and so on. For All/success/error etc.

  12. Tallies by hour, day, week, month etc.

  13. Throughput calculation by the second, minute,hour,day depending on the domain.

  14. Error rates by second, minute,hour,day depending on the domain.

  15. Drop rates – in some systems requests can time out. You might need to track these.

  16. Uptime.

  17. Load – number of concurrent invocations etc.

  18. Memory usage (very very rough in Java).

  19. Data transfer – if you can calculate request and response sizes.

This list is by no means complete, and if you have any suggestions then drop me a line at gary(at)garyleeson.com.

You can also from the above work out what invocations were executing concurrently which can help in figuring out the hog processes when certain “odd� things occur that depend on when and what things are running; For example when two processes use a lock to access some resource. When run individually everything runs fine. When they run concurrently one gets the lock and the other has to wait; if the process that has to wait has a hard time constraint then you might have issues.

Another thing to do is make sure that all this is kept as an in-memory database for performance reasons – using a traditional DB backend such as postgres could have quite an impact; this does not prevent you from building in a mechanism to flush to backing store during quiet periods or every 5 minutes or so.

<meta name="GENERATOR" content="OpenOffice.org 2.0-pre (Linux)" /><meta name="AUTHOR" content="Gary Leeson" /><meta name="CREATED" content="20060903;21231800" /><meta name="CHANGEDBY" content="Gary Leeson" /><meta name="CHANGED" content="20060903;22120900" /><br /> <style> <!-- @page { size: 21cm 29.7cm; margin: 2cm } P { margin-bottom: 0.21cm } --> </style> </p> <p style="margin-bottom: 0cm">Do you know how well your application functions? Can you tell me what is the average time for a request to be handled? the worst? Can you tell me how your application functions with time? If not then you have missed one of the most common “unwrittenâ€? requirements – that of instrumenting your code.</p> <p style="margin-bottom: 0cm"> <p style="margin-bottom: 0cm">Hang-on I hear you say!! you can profile the application and unit tests can give you this information. Yes this may be true, but it is never a substitute for building into your code instrumentation as you go along. You will never know when it will come handy, and anyway testing your code on your development machine is rarely anything like running it on the real deployment environment.</p> <p style="margin-bottom: 0cm"> <p style="margin-bottom: 0cm">For example, many years ago I developed some middle-ware for a large and very profitable international corporation. The piece of code was to mediate between the front-end and the back-end billing/resource system. Development went well and as usual I inserted instrumentation as I went along before the product was released into the production environment under the watchful eye of application management group. To help roll out the product there was a massive marketing campaign – TV, billboards the whole nine yards; first time I have ever seem anything I developed up on TV.</p> <p style="margin-bottom: 0cm"> <p style="margin-bottom: 0cm">About a month latter my line manager (a really nice lady) came to me and said “Gary there seems to be a problem with the system; I have just had my arse kicked by sales and marketing. The product is a great success but there are a lot of unhappy customers who get ‘time out’ errors from the GUI, and the GUI guys say its because the connection to your middle ware is timing out, and the applications support environment says the 3 machines in the deployment cluster are fine. Could you investigate and get back to me?â€? Sound familiar? Talk about a bombshell and a potential career limiting move. With the manager there I said “lets look at the instrumentation and performance screensâ€?; A couple of minutes latter the situation came clear. Two of the three machines in the middle-ware cluster were “downâ€? for the times and periods mentioned but for different reasons; one machine was “upâ€? and running but there were no performance metrics; the other machine was not up at all!!! So in effect we were running at 1/3<sup>rd</sup> capacity – no wonder we had problems. We paid a quick visit to application support. To cut a long story short, it turned out the machine which was down was “being upgradedâ€? – why that was done in the “busy periodâ€? and why it took a week would be another article; the machine that was “upâ€? but had no statistics turned out not to be included in the cluster configuration at all!!!</p> <p style="margin-bottom: 0cm"> <p style="margin-bottom: 0cm">These were soon fixed and everything went smoothly – especially when I wrote a script to monitor the scripts and analyze the results. So my manager would then know on a day/week/month basis how many actual transactions went through the system, how long they took, what the system throughput was and what we were capable of supporting, when the transactions took place. As a result my manager did not need to ask sales and marketing how many sales went through, and did not need to access application support unless from the statistics she was told one or more of the servers was down – where upon, she went looking for application support.</p> <p style="margin-bottom: 0cm"> <p style="margin-bottom: 0cm">I suppose the moral of this little story is if you don’t instrument your code you will never know you have a problem until someone with more power and clout than you comes looking for you with a big club embedded with nails and a very bad attitude.</p> <p style="margin-bottom: 0cm"> <p style="margin-bottom: 0cm">In the next blog I will go through the types of instrumentation and performance metrics are useful to put in your code.</p> <p style="margin-bottom: 0cm"> <p style="margin-bottom: 0cm"> <p style="margin-bottom: 0cm"> <p style="margin-bottom: 0cm"><!--86fcc9be86da0c6bc50d3b0f1e4167c7--></p> <div class="post-info"> </div> <div class="postmeta"> <p>Tags: </p> </div> <!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> <rdf:Description rdf:about="http://www.garyleeson.com/index.php/2006/09/03/instrument-your-code-young-man-and-do-it-now-part-1/" dc:identifier="http://www.garyleeson.com/index.php/2006/09/03/instrument-your-code-young-man-and-do-it-now-part-1/" dc:title="Instrument your code young man…. and do it now (Part 1)" trackback:ping="http://www.garyleeson.com/index.php/2006/09/03/instrument-your-code-young-man-and-do-it-now-part-1/trackback/" /> </rdf:RDF> --> <div class="post-footer"> </div> </div> </div> <div class="post"> <p class="post-date">Tue 22 Aug 2006</p> <div class="post-info"> <h2 class="post-title"><a href="../../../2006/08/22/rest-is-not-just-java-servlets/index.html" rel="bookmark" title="Permanent Link: REST is not just Java Servlets!!!">REST is not just Java Servlets!!!</a></h2> <p>Posted by gremlin under <a href="index.html" title="View all posts in Application Servers" rel="category tag">Application Servers</a>, <a href="../java/index.html" title="View all posts in Java" rel="category tag">Java</a> <br/> <a href="../../../2006/08/22/rest-is-not-just-java-servlets/index.html#comments" title="Comment on REST is not just Java Servlets!!!">1 Comment</a></p> </div> <div class="post-content"> <p>The REST (<strong><a target="_blank" href="http://en.wikipedia.org/wiki/REST">Representational State Transfer</a>) </strong>is a hot topic in IT development world at the moment. Some see it as complimentary to SOAP, XML-RPC etc others as a replacement; and even within the REST community there are various flavours: REST-Purists who only accept the four basic http verbs (PUT, GET, POST, DELETE) which map generally onto the Create,Read, Update and Delete (CRUD) operations of the database world; the REST-LIKE group who are more pragmatic since there are situations where these verbs don’t cleanly map to the problem domain AND also can use other aspects of the HTTP protocol such as cookies for session management.</p> <p>REST has really taken off with <a target="_blank" href="http://en.wikipedia.org/wiki/Ajax_(programming)">AJAX</a> and the new slick interfaces such as <a href="http://maps.google.com/">Google Maps. </a>due to its sheer simplicity unlike SOAP and to some degree XML-RPC which generally involve translating client format – to say SOAP format which on the target server is then translated back into some other server internal format this is a recipie for slowness.</p> <p>Where do I stand? well with most things I am not a religious fundamentalist so I tend towards the REST-Like group. The basic four verbs work for about 80% of the development I do, but you do have to be flexible. I do like using the excellent <a target="_blank" href="http://xstream.codehaus.org/">XStream</a> library which frees me from the XSD/DTD->Java step and allows me to serialize complex POJO’s to and from XML with three lines of code (the library does not do “elements” though) so is simple and easy to use – gets my vote and I’m a fan of <a href="http://en.wikipedia.org/wiki/Occums_razor">OCCAM.</a></p> <p>One thing I have noticed within the JAVA world is the assumption that REST = web application by implication servlets/JSP. This is simply not true. Yes HTTP and HTTPS are the back-bones of the web, but it is only one part of the web. HTTP is not HTML – even though is can return HTML, XML or any other MIME type; and it does not need a web server to run. I have to admit that most libraries that allow you implement REST under JAVA are based on servlets (<a href="http://gomba.sourceforge.net/">GOMBA</a>, and <a target="_blank" href="http://www.restlet.org/">RESTLet)</a> so are tied to jsp/servlet containers; this is why there is mindset link in the Java community between REST and the WEB or more specifically between REST and Java Servlets.</p> <p>I find it a bit irksome in that you don’t need <a target="_blank" href="http://tomcat.apache.org/">Tomcat</a> or a full <a href="http://www.mortbay.org/jetty/index.html">Jetty engine</a> to implement a REST server within you application or application server – and often you get a much better performance and smaller memory footprint if you don’t. For example I have implemented a REST application server that does not use servlets. A full Jetty server (6.0rc1) takes up around 21MB of my Linux box and that does not include my application. If I however just take the JETTY core which provides the fast networking library code, dump servlets, JSP and HTML handlers and add Spring and XStream and my app code I can generally build a full application in under 5MB. You might think that is not much – but in applicance development, PDA’s, and other embedded development every byte and processor cycle counts, and with Apache’s <a target="_blank" href="http://jakarta.apache.org/commons/daemon/">Daemon</a> its easy to develop Linux and Windows services that start up at system boot time.<br /> A good pod cast I have found discussing REST is the ever excellent Java Posse groups <a target="_blank" href="http://media.libsyn.com/media/dickwall/JavaPosse076.mp3">pod-cast #76</a> </p> <p><!--01a7dbd96d69ced44e595417711c85e7--> </p> <p><!--95130f6def9e271df8b53b892d6ee36d--></p> <div class="post-info"> </div> <div class="postmeta"> <p>Tags: </p> </div> <!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> <rdf:Description rdf:about="http://www.garyleeson.com/index.php/2006/08/22/rest-is-not-just-java-servlets/" dc:identifier="http://www.garyleeson.com/index.php/2006/08/22/rest-is-not-just-java-servlets/" dc:title="REST is not just Java Servlets!!!" trackback:ping="http://www.garyleeson.com/index.php/2006/08/22/rest-is-not-just-java-servlets/trackback/" /> </rdf:RDF> --> <div class="post-footer"> </div> </div> </div> <p class="center"></p> </div> <div id="sidebar"> <ul> <li id="calendar"> <table id="wp-calendar" summary="Calendar"> <caption>March 2015</caption> <thead> <tr> <th abbr="Monday" scope="col" title="Monday">M</th> <th abbr="Tuesday" scope="col" title="Tuesday">T</th> <th abbr="Wednesday" scope="col" title="Wednesday">W</th> <th abbr="Thursday" scope="col" title="Thursday">T</th> <th abbr="Friday" scope="col" title="Friday">F</th> <th abbr="Saturday" scope="col" title="Saturday">S</th> <th abbr="Sunday" scope="col" title="Sunday">S</th> </tr> </thead> <tfoot> <tr> <td abbr="February" colspan="3" id="prev"><a href="../../../2015/02/index.html" title="View posts for February 2015">« Feb</a></td> <td class="pad"> </td> <td colspan="3" id="next" class="pad"> </td> </tr> </tfoot> <tbody> <tr> <td colspan="6" class="pad"> </td><td>1</td> </tr> <tr> <td>2</td><td>3</td><td><a href="../../../2015/03/04/index.html" title="Maeve’s a “Hacker”">4</a></td><td>5</td><td>6</td><td>7</td><td>8</td> </tr> <tr> <td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td id="today">14</td><td>15</td> </tr> <tr> <td>16</td><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td> </tr> <tr> <td>23</td><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td><td>29</td> </tr> <tr> <td>30</td><td>31</td> <td class="pad" colspan="5"> </td> </tr> </tbody> </table> </li> <li id="recent-posts-3" class="widget widget_recent_entries"> <h2>Recent Posts</h2><ul><li> <ul> <li><a href="../../../2015/03/04/maeves-a-hacker/index.html" title="Maeve’s a “Hacker”">Maeve’s a “Hacker” </a></li> <li><a href="../../../2015/02/21/action-maeve/index.html" title="Action Maeve">Action Maeve </a></li> <li><a href="../../../2015/02/14/valentines-meal/index.html" title="Valentines Meal">Valentines Meal </a></li> <li><a href="../../../2014/10/10/excitement-and-car-crashes-in-donabate/index.html" title="Excitement and car crashes in Donabate">Excitement and car crashes in Donabate </a></li> <li><a href="../../../2014/10/09/love-can-be-a-surprising-thing/index.html" title="Love can be a surprising thing">Love can be a surprising thing </a></li> </ul> </li></ul></li> <li id="search"> <h2><label for="s">Search:</label></h2> <ul> <li> <form id="searchform" method="get" action="http://www.garyleeson.com/index.php/category/tech/application-servers/"> <div style="text-align:center"> <p><input type="text" name="s" id="s" size="15" /></p> <p><input type="submit" name="submit" value="Search" /></p> </div> </form> </li> </ul> </li> <li id="meta-4" class="widget widget_meta"><h2>Meta</h2><ul><li> <ul> <li><a href="../../../../wp-login.html">Log in</a></li> <li><a href="../../../feed/index.html" title="Syndicate this site using RSS 2.0">Entries <abbr title="Really Simple Syndication">RSS</abbr></a></li> <li><a href="../../../comments/feed/index.html" title="The latest comments to all posts in RSS">Comments <abbr title="Really Simple Syndication">RSS</abbr></a></li> <li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress.org</a></li> </ul> </li></ul></li><li id="twitter-1" class="widget widget_twitter"><h2><a href="http://twitter.com/garyleeson" class="twitter_title_link">Twitter</a></h2><ul><li><ul class="twitter"><li>No public Twitter messages.</li></ul></li></ul></li> </ul> </div> <div id="footer"> <p><small> <a href="../../../../index.html" title="Gremlin’s Fireside Chat">Gremlin’s Fireside Chat</a> is powered by <a href="http://wordpress.org/" title="Powered by WordPress 2.8, state-of-the-art semantic personal publishing platform">WordPress 2.8</a> and delivered to you in 1.451 seconds using 26 queries. <br /> Theme: <a href="http://ajaydsouza.com/wordpress/wpthemes/connections-reloaded/" title="Powered by Connections Reloaded">Connections Reloaded v2.1</a> by <a href="http://ajaydsouza.com/" title="Visit Ajay's Blog">Ajay D'Souza</a>. Derived from <a href="http://vanillamist.com/blog/" title="Connections Theme">Connections</a>. </small></p> <script src="http://stats.wordpress.com/e-201511.js" type="text/javascript"></script> <script type="text/javascript"> st_go({blog:'14205214',v:'ext',post:'0'}); var load_cmc = function(){linktracker_init(14205214,0,2);}; if ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc); else load_cmc(); </script> </div> <!-- End id="footer" --> </div> <!-- End id="main" --> </div> <!-- End id="rap" --> </body> <!-- Mirrored from www.garyleeson.com/index.php/category/tech/application-servers/ by HTTrack Website Copier/3.x [XR&CO'2013], Sat, 14 Mar 2015 18:38:48 GMT --> </html>