{"id":3963,"date":"2016-12-19T18:30:36","date_gmt":"2016-12-20T00:30:36","guid":{"rendered":"https:\/\/justinparrtech.com\/JustinParr-Tech\/?p=3963"},"modified":"2016-12-19T18:30:36","modified_gmt":"2016-12-20T00:30:36","slug":"your-application-should-include-a-broker-tier","status":"publish","type":"post","link":"https:\/\/justinparrtech.com\/JustinParr-Tech\/your-application-should-include-a-broker-tier\/","title":{"rendered":"Your Application Should Include a Broker Tier"},"content":{"rendered":"<p>In any major software development project, a broker tier is a critical element.<\/p>\n<p>We&#8217;ll examine what a broker tier is, what it does, and several advantages to having one.<\/p>\n<p><!--more--><\/p>\n<p>&nbsp;<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/your-application-should-include-a-broker-tier\/#what-is-a-broker-tier\" >What is a Broker Tier?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/your-application-should-include-a-broker-tier\/#easily-support-different-technology-stacks\" >Easily Support\u00a0Different Technology Stacks<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/your-application-should-include-a-broker-tier\/#logging-and-non-repudiation\" >Logging and Non-Repudiation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/your-application-should-include-a-broker-tier\/#build-in-redundancy-high-availability\" >Build in Redundancy \/ High Availability<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/your-application-should-include-a-broker-tier\/#build-in-application-performance-monitoring-apm\" >Build In Application Performance Monitoring (APM)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/your-application-should-include-a-broker-tier\/#conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"what-is-a-broker-tier\"><\/span>What is a Broker Tier?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A broker sits between the application&#8217;s main code, and any other external components.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3965\" src=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-Tier.png\" alt=\"broker-tier\" width=\"1024\" height=\"588\" srcset=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-Tier.png 1024w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-Tier-300x172.png 300w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-Tier-768x441.png 768w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-Tier-600x345.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>On the left, we see a typical application whose code module makes external calls directly.<\/p>\n<p>On the right, we see an application that leverages a broker tier. \u00a0The application&#8217;s code module makes a call to the broker, and the broker makes all external calls on behalf of the code module.<\/p>\n<p><strong>At first, this seems like needless overhead, but there are some very good reasons to include a broker tier in any non-trivial application.<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"easily-support-different-technology-stacks\"><\/span>Easily Support\u00a0Different Technology Stacks<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>With a broker model, supporting any new technology stack requires few if any changes to the main code module.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3972\" src=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-Platform-Support.png\" alt=\"broker-platform-support\" width=\"870\" height=\"594\" srcset=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-Platform-Support.png 870w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-Platform-Support-300x205.png 300w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-Platform-Support-768x524.png 768w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-Platform-Support-600x410.png 600w\" sizes=\"auto, (max-width: 870px) 100vw, 870px\" \/><\/p>\n<p>For example, if migrating from Oracle database to MS SQL database, then the database broker can be modified with MS SQL connection strings and query primitives, rather than having to search through the entire code base looking for database calls. \u00a0Of course, triggers and stored procedures that encapsulate part of the application logic will need to be re-written, regardless.<\/p>\n<p>Likewise, if migrating from a Windows-based CIFS file server to a Unix-compatible NFS file server, only the file broker must be updated to use Unix path notation and NFS calling convention, rather than Windows path notation and CIFS calling convention.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3980\" src=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-File-Abstraction-1.png\" alt=\"broker-file-abstraction\" width=\"900\" height=\"502\" srcset=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-File-Abstraction-1.png 900w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-File-Abstraction-1-300x167.png 300w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-File-Abstraction-1-768x428.png 768w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-File-Abstraction-1-600x335.png 600w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p>From the main code module&#8217;s perspective, the call to read or write a file can be generic, abstracted by a label that&#8217;s configured within the broker to point to a physical path. \u00a0The main code module never needs to know the physical path, whether it&#8217;s local, remote, CIFS, Unix, or something completely different, such as database BLOBs or JSON object storage.<\/p>\n<p>In the example above, &#8220;Path1&#8221; is a symbol that the main code module uses when it wants to write a file, and each of the three brokers can be configured to map &#8220;Path1&#8221; to a valid physical location based on each respective file system&#8217;s path naming conventions.<\/p>\n<p>Meanwhile, the main code module doesn&#8217;t need to worry about the full path, and no code change would be\u00a0required, should the path change, or if the underlying file server technology changes.<\/p>\n<p><strong>Using a broker simplifies configuration changes, and provides a modular approach to supporting multiple technology stacks, without having to modify the main application code.<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"logging-and-non-repudiation\"><\/span>Logging and Non-Repudiation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Any application should include robust logs that aid in troubleshooting, as well as non-repudiation.<\/p>\n<p>Trying to incorporate logging in to an application often results in a dilemma around determining the correct atomic level of logging, as well as what elements to include in the log.<\/p>\n<p>Having the broker perform the logging avoids needless verbosity, while ensuring that an entire transaction and all of its components end up in the log.<\/p>\n<p>When coupled with time stamps, digital signatures, and other cryptographic artifacts, transaction-level logging can also provide the basis for\u00a0non-repudiation &#8211; the concept that a particular transaction can&#8217;t be questioned, because there is evidence of every transaction.<\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"build-in-redundancy-high-availability\"><\/span>Build in Redundancy \/ High Availability<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Normally, when a critical component fails, such as a file server or database, the result is that the entire application crashes due to a cascade failure, and could even result in data loss.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3988\" src=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Cascade-Failure.png\" alt=\"cascade-failure\" width=\"299\" height=\"500\" srcset=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Cascade-Failure.png 360w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Cascade-Failure-179x300.png 179w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Cascade-Failure-359x600.png 359w\" sizes=\"auto, (max-width: 299px) 100vw, 299px\" \/><\/p>\n<p>In the example above, the database fails, resulting in the database broker failing, resulting in a failure within the primary code module, which in turn causes the entire application to fail.<\/p>\n<p>Typical high availability strategies rely on multiple copies of the data, or multiple instances, such that a failure of one component doesn&#8217;t result in a complete failure.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3990\" src=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/DB-High-Availability-591x600.png\" width=\"492\" height=\"500\" srcset=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/DB-High-Availability-591x600.png 591w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/DB-High-Availability-295x300.png 295w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/DB-High-Availability.png 630w\" sizes=\"auto, (max-width: 492px) 100vw, 492px\" \/><\/p>\n<p>In the example above, information stored by the application in the database is replicated from the primary instance to the standby instance. \u00a0Rather than communicate directly with one of the database instances directly, the application talks to a high-availability layer. \u00a0If the primary database instance fails, the application is\u00a0protected from failure by the high-availability layer, which automatically switches over to the standby database instance.<\/p>\n<p>Although at first, this seems like a good way to handle redundancy and high-availability, there are a number of potential problems:<\/p>\n<ul>\n<li>Licensing for high availability often costs significantly more than a standalone instance<\/li>\n<li>Configuration is complex, and difficult to troubleshoot<\/li>\n<li>Sometimes, failover doesn&#8217;t occur automatically<\/li>\n<li>Slow replication can cause application performance issues, or could result in data loss<\/li>\n<li>Some high-availability strategies, such as clustering, don&#8217;t actually make a second copy of the data. \u00a0Although the instance may be protected against crashing, the data itself isn&#8217;t protected against corruption or deletion.<\/li>\n<\/ul>\n<p>Building fault tolerance in to the broker tier is a much better approach.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-3992\" src=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-High-Availability-1-600x413.png\" alt=\"broker-high-availability\" width=\"600\" height=\"413\" srcset=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-High-Availability-1-600x413.png 600w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-High-Availability-1-300x207.png 300w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-High-Availability-1-768x529.png 768w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-High-Availability-1.png 860w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>In the model above, the file broker and database broker each make an extra write in to a\u00a0standby environment, to an extra copy of the file server and database (respectively).<\/p>\n<p>In the event of the failure of a component in the primary environment, the broker itself can simply swing all of its read operations over to the standby.<\/p>\n<p>The primary can be rebuilt as a copy of the standby, or missing transactions can be written to a queue on the standby, and applied later when the primary becomes available.<\/p>\n<p><strong>Using a broker for redundancy and high availability is a relatively simple and very reliable way to insure against unplanned down time and data loss.<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"build-in-application-performance-monitoring-apm\"><\/span>Build In Application Performance Monitoring (APM)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>For complex, distributed applications, a third-party APM tool sits between various layers of the application, gathering data, which is then crunched within the APM platform, yielding performance logging, alerting for sub-optimal performance, and realtime status (e.g. dashboard).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-3995\" src=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/APM-600x394.png\" alt=\"apm\" width=\"600\" height=\"394\" srcset=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/APM-600x394.png 600w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/APM-300x197.png 300w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/APM-768x505.png 768w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/APM.png 913w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>A decent APM platform can cost tens or hundreds of thousands of dollars, depending upon the extent of the features and deployment.<\/p>\n<p>Conversely, by gathering a few statistics from the broker module, the application can perform its own APM.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-3998\" src=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-APM-600x376.png\" alt=\"broker-apm\" width=\"600\" height=\"376\" srcset=\"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-APM-600x376.png 600w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-APM-300x188.png 300w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-APM-768x482.png 768w, https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-content\/uploads\/Broker-APM.png 957w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>For example, by simply timing each query that passes through the database broker, the application can build a statistical model using any number of variables, to determine if any given query executed quickly or slowly.<\/p>\n<p>These statistics can be stored in a performance log for review, or posted to a realtime display, such as a dashboard. \u00a0Further, alerts can be automatically sent to application administrators in the event of application slowness.<\/p>\n<p><strong>Building Application Performance Monitoring (APM) in to the broker tier can save significant cost, and provide relevant business capabilities.<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In addition to making your application lean and modular, broker architecture allows for sophisticated and powerful capabilities:<\/p>\n<ul>\n<li>Brokers are modular, which means that migrating to various technology stacks is just a matter of copying the existing broker code, creating a new module, and configuring the particulars of the new technology stack.<\/li>\n<li>Brokers provide an easy way to add logging and non-repudiation to any application.<\/li>\n<li>Brokers provide an easy way to add high-availability and redundancy for underlying technology stacks, rather than having to rely on expensive, complex, and perhaps unreliable component-level high-availability schemes.<\/li>\n<li>Brokers provide an easy way to add APM to any application, allowing for the native capability to perform statistical performance monitoring, in support of performance logging, alerting, and &#8220;dashboard&#8221;-style realtime status, without the need to acquire and implement expensive APM tools.<\/li>\n<\/ul>\n<p><strong>Every major application should be built with a broker architecture in mind.<\/strong><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In any major software development project, a broker tier is a critical element. We&#8217;ll examine what a broker tier is, what it does, and several advantages to having one.<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-3963","post","type-post","status-publish","format-standard","hentry","category-good-design-bad-design"],"_links":{"self":[{"href":"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-json\/wp\/v2\/posts\/3963","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-json\/wp\/v2\/comments?post=3963"}],"version-history":[{"count":10,"href":"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-json\/wp\/v2\/posts\/3963\/revisions"}],"predecessor-version":[{"id":4000,"href":"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-json\/wp\/v2\/posts\/3963\/revisions\/4000"}],"wp:attachment":[{"href":"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-json\/wp\/v2\/media?parent=3963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-json\/wp\/v2\/categories?post=3963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/justinparrtech.com\/JustinParr-Tech\/wp-json\/wp\/v2\/tags?post=3963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}