Archive for September, 2006

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> <!--- middle (main content) column content end --> </div> <div id="sidebar"> <ul> <li id="calendar"> <table id="wp-calendar" summary="Calendar"> <caption>September 2006</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="August" colspan="3" id="prev"><a href="../08/index.html" title="View posts for August 2006">« Aug</a></td> <td class="pad"> </td> <td abbr="October" colspan="3" id="next"><a href="../10/index.html" title="View posts for October 2006">Oct »</a></td> </tr> </tfoot> <tbody> <tr> <td colspan="4" class="pad"> </td><td>1</td><td>2</td><td><a href="03/index.html" title="Instrument your code young man…. and do it now (Part 1)">3</a></td> </tr> <tr> <td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td> </tr> <tr> <td><a href="11/index.html" title="Instrument your code young man – Part 2">11</a></td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td> </tr> <tr> <td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td> </tr> <tr> <td>25</td><td>26</td><td>27</td><td>28</td><td>29</td><td>30</td> <td class="pad" colspan="1"> </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/2006/09/"> <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.633 seconds using 24 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/2006/09/ by HTTrack Website Copier/3.x [XR&CO'2013], Sat, 14 Mar 2015 18:35:17 GMT --> </html>