{"id":481,"date":"2024-12-06T20:02:29","date_gmt":"2024-12-06T19:02:29","guid":{"rendered":"https:\/\/www.systemdeveloper.nl\/tech\/?p=481"},"modified":"2024-12-06T20:07:12","modified_gmt":"2024-12-06T19:07:12","slug":"evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance","status":"publish","type":"post","link":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/","title":{"rendered":"Evolving Our Database Class \u2013 Introducing Exponential Backoff and Enhanced Performance"},"content":{"rendered":"<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\">In a previous blog, we showcased a robust database class designed to streamline database interactions and handle common issues like deadlocks gracefully. While the original version was reliable, we&#8217;ve since implemented significant improvements to address real-world challenges, particularly in high-concurrency scenarios.<\/p>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\">Today, we&#8217;re excited to introduce <strong>exponential backoff<\/strong> in our retry mechanism, enhanced logging, and caching capabilities. These changes improve system reliability, reduce server load, and provide deeper insights into system performance.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<h3 class=\"wp-block-heading\" id=\"the-key-features-of-the-updated-database-class\"><strong>The Key Features of the Updated Database Class<\/strong><\/h3>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<h4 class=\"wp-block-heading\" id=\"1-exponential-backoff-in-retries\"><strong>1. Exponential Backoff in Retries<\/strong><\/h4>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\">Deadlocks are a common occurrence in high-concurrency environments. When multiple processes compete for the same resource, retries can result in cascading failures if not managed carefully. Previously, our class used a fixed wait time of 100ms between retries. While effective in simple scenarios, this approach can overwhelm the database under heavy load.<\/p>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\"><strong>What&rsquo;s New?<\/strong><\/p>\n\n\n<ul class=\"wp-block-list wp-block-list\">\n<li>With exponential backoff, the retry wait time doubles with each failed attempt. For example:<ul class=\"wp-block-list wp-block-list\">\n<li>Retry 1: 100ms<\/li>\n\n\n\n<li>Retry 2: 200ms<\/li>\n\n\n\n<li>Retry 3: 400ms<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>This approach spreads out retries, reducing contention and allowing the database to recover.<\/li>\n<\/ul>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\"><strong>Code Implementation:<\/strong><\/p>\n\n\n<pre class=\"wp-block-code\"><div class=\"copy-to-clipboard\">\n<span>Copied!<\/span><button class=\"click-to-copy-button\" title=\"Copy to clipboard\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewbox=\"0 0 32 32\" stroke=\"currentcolor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" width=\"24\" height=\"24\" fill=\"none\">\n  <path d=\"M12.9975 10.7499L11.7475 10.7499C10.6429 10.7499 9.74747 11.6453 9.74747 12.7499L9.74747 21.2499C9.74747 22.3544 10.6429 23.2499 11.7475 23.2499L20.2475 23.2499C21.352 23.2499 22.2475 22.3544 22.2475 21.2499L22.2475 12.7499C22.2475 11.6453 21.352 10.7499 20.2475 10.7499L18.9975 10.7499Z\"><\/path>\n  <path d=\"M17.9975 12.2499L13.9975 12.2499C13.4452 12.2499 12.9975 11.8022 12.9975 11.2499L12.9975 9.74988C12.9975 9.19759 13.4452 8.74988 13.9975 8.74988L17.9975 8.74988C18.5498 8.74988 18.9975 9.19759 18.9975 9.74988L18.9975 11.2499C18.9975 11.8022 18.5498 12.2499 17.9975 12.2499Z\"><\/path>\n  <path d=\"M13.7475 16.2499L18.2475 16.2499\"><\/path>\n  <path d=\"M13.7475 19.2499L18.2475 19.2499\"><\/path>\n<\/svg><\/button><textarea>private function executeQueryWithRetry($callback) {\n    $retries = 0;\n    while ($retries maxRetries) {\n        try {\n            $this-&gt;pdo-&gt;beginTransaction();\n            $result = $callback();\n            $this-&gt;pdo-&gt;commit();\n            return $result;\n        } catch (PDOException $e) {\n            $this-&gt;pdo-&gt;rollBack();\n            if ($e-&gt;getCode() == '40001') { \/\/ Deadlock\n                $this-&gt;log('warning', \"Deadlock detected, retrying... (Attempt \" . ($retries + 1) . \")\");\n                $retries++;\n                $waitTime = pow(2, $retries) * 100000; \/\/ Exponential wait in microseconds\n                usleep($waitTime);\n            } else {\n                throw $e;\n            }\n        }\n    }\n    throw new Exception(\"Query failed after maximum retries.\");\n}<\/textarea>\n<\/div><code>private function executeQueryWithRetry($callback) {\n    $retries = 0;\n    while ($retries &lt; $this-&gt;maxRetries) {\n        try {\n            $this-&gt;pdo-&gt;beginTransaction();\n            $result = $callback();\n            $this-&gt;pdo-&gt;commit();\n            return $result;\n        } catch (PDOException $e) {\n            $this-&gt;pdo-&gt;rollBack();\n            if ($e-&gt;getCode() == '40001') { \/\/ Deadlock\n                $this-&gt;log('warning', \"Deadlock detected, retrying... (Attempt \" . ($retries + 1) . \")\");\n                $retries++;\n                $waitTime = pow(2, $retries) * 100000; \/\/ Exponential wait in microseconds\n                usleep($waitTime);\n            } else {\n                throw $e;\n            }\n        }\n    }\n    throw new Exception(\"Query failed after maximum retries.\");\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<h4 class=\"wp-block-heading\" id=\"2-why-exponential-backoff-matters\"><strong>2. Why Exponential Backoff Matters<\/strong><\/h4>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\">While exponential backoff doesn&rsquo;t change the theoretical probability of success (determined by the probability of a deadlock on each attempt), it significantly improves <strong>practical outcomes<\/strong> in real-world systems.<\/p>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\"><strong>Without Backoff:<\/strong><\/p>\n\n\n<ul class=\"wp-block-list wp-block-list\">\n<li>All retries occur at fixed intervals (e.g., 100ms).<\/li>\n\n\n\n<li>Multiple processes retry simultaneously, causing spikes in server load and increasing contention risks.<\/li>\n<\/ul>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\"><strong>With Backoff:<\/strong><\/p>\n\n\n<ul class=\"wp-block-list wp-block-list\">\n<li>Retries are staggered, spreading out database load.<\/li>\n\n\n\n<li>The database has more time to recover between retries, reducing the likelihood of new deadlocks.<\/li>\n<\/ul>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\">Here&rsquo;s how success probabilities accumulate over retries:<\/p>\n\n\n\n<figure class=\"wp-block-table aligncenter\"><table class=\"has-fixed-layout\"><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong>Retries<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Probability of Success<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Cumulative Probability <\/strong><br><strong>of Success<\/strong><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">1<\/td><td class=\"has-text-align-center\" data-align=\"center\">80%<\/td><td class=\"has-text-align-center\" data-align=\"center\">80%<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">2<\/td><td class=\"has-text-align-center\" data-align=\"center\">16%<\/td><td class=\"has-text-align-center\" data-align=\"center\">96%<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">3<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.2%<\/td><td class=\"has-text-align-center\" data-align=\"center\">99.2%<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">4<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.64%<\/td><td class=\"has-text-align-center\" data-align=\"center\">99.84%<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">5<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.128%<\/td><td class=\"has-text-align-center\" data-align=\"center\">99.97%<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">10<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.0001%<\/td><td class=\"has-text-align-center\" data-align=\"center\">~100%<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\"><strong>Example: Reducing Server Load<\/strong><\/p>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\">Imagine a server experiencing 100 concurrent retries due to deadlocks:<\/p>\n\n\n<ul class=\"wp-block-list wp-block-list\">\n<li>\n<strong>Without backoff:<\/strong> <br>All 100 processes retry after 100ms, creating a massive spike in load.<\/li>\n\n\n\n<li>\n<strong>With backoff:<\/strong> <br>Processes retry at different intervals (100ms, 200ms, 400ms, etc.), reducing contention and preventing additional failures.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<h4 class=\"wp-block-heading\" id=\"3-redis-caching-for-faster-queries\"><strong>3. Redis Caching for Faster Queries<\/strong><\/h4>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\">To further improve performance, we&rsquo;ve integrated Redis caching. Frequently accessed query results are stored in Redis, reducing load on the database and speeding up response times.<\/p>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\"><strong>How It Works:<\/strong><\/p>\n\n\n<ul class=\"wp-block-list wp-block-list\">\n<li>Queries and parameters are hashed into unique cache keys.<\/li>\n\n\n\n<li>Results are stored in Redis with a configurable TTL (Time-to-Live).<\/li>\n\n\n\n<li>Cached results are returned immediately if available, bypassing the database.<\/li>\n<\/ul>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\"><strong>Snippet:<\/strong><\/p>\n\n\n<pre class=\"wp-block-code\"><div class=\"copy-to-clipboard\">\n<span>Copied!<\/span><button class=\"click-to-copy-button\" title=\"Copy to clipboard\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewbox=\"0 0 32 32\" stroke=\"currentcolor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" width=\"24\" height=\"24\" fill=\"none\">\n  <path d=\"M12.9975 10.7499L11.7475 10.7499C10.6429 10.7499 9.74747 11.6453 9.74747 12.7499L9.74747 21.2499C9.74747 22.3544 10.6429 23.2499 11.7475 23.2499L20.2475 23.2499C21.352 23.2499 22.2475 22.3544 22.2475 21.2499L22.2475 12.7499C22.2475 11.6453 21.352 10.7499 20.2475 10.7499L18.9975 10.7499Z\"><\/path>\n  <path d=\"M17.9975 12.2499L13.9975 12.2499C13.4452 12.2499 12.9975 11.8022 12.9975 11.2499L12.9975 9.74988C12.9975 9.19759 13.4452 8.74988 13.9975 8.74988L17.9975 8.74988C18.5498 8.74988 18.9975 9.19759 18.9975 9.74988L18.9975 11.2499C18.9975 11.8022 18.5498 12.2499 17.9975 12.2499Z\"><\/path>\n  <path d=\"M13.7475 16.2499L18.2475 16.2499\"><\/path>\n  <path d=\"M13.7475 19.2499L18.2475 19.2499\"><\/path>\n<\/svg><\/button><textarea>$cacheKey = $this-&gt;generateCacheKey($sql, $params);\nif ($cachedResult = $this-&gt;redis-&gt;get($cacheKey)) {\n    return json_decode($cachedResult, true);\n}<\/textarea>\n<\/div><code>$cacheKey = $this-&gt;generateCacheKey($sql, $params);\nif ($cachedResult = $this-&gt;redis-&gt;get($cacheKey)) {\n    return json_decode($cachedResult, true);\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<h4 class=\"wp-block-heading\" id=\"4-asynchronous-logging-with-redis\"><strong>4. Asynchronous Logging with Redis<\/strong><\/h4>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\">To avoid blocking the main application flow, our logging system now uses Redis as a queue for log messages. This ensures that logging doesn&rsquo;t impact performance, even under heavy load.<\/p>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\"><strong>How It Works:<\/strong><\/p>\n\n\n<ul class=\"wp-block-list wp-block-list\">\n<li>Log messages are pushed to a Redis queue.<\/li>\n\n\n\n<li>A worker process consumes messages from the queue and writes them to a file.<\/li>\n<\/ul>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\"><strong>Example Worker Process:<\/strong><\/p>\n\n\n<pre class=\"wp-block-code\"><div class=\"copy-to-clipboard\">\n<span>Copied!<\/span><button class=\"click-to-copy-button\" title=\"Copy to clipboard\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewbox=\"0 0 32 32\" stroke=\"currentcolor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" width=\"24\" height=\"24\" fill=\"none\">\n  <path d=\"M12.9975 10.7499L11.7475 10.7499C10.6429 10.7499 9.74747 11.6453 9.74747 12.7499L9.74747 21.2499C9.74747 22.3544 10.6429 23.2499 11.7475 23.2499L20.2475 23.2499C21.352 23.2499 22.2475 22.3544 22.2475 21.2499L22.2475 12.7499C22.2475 11.6453 21.352 10.7499 20.2475 10.7499L18.9975 10.7499Z\"><\/path>\n  <path d=\"M17.9975 12.2499L13.9975 12.2499C13.4452 12.2499 12.9975 11.8022 12.9975 11.2499L12.9975 9.74988C12.9975 9.19759 13.4452 8.74988 13.9975 8.74988L17.9975 8.74988C18.5498 8.74988 18.9975 9.19759 18.9975 9.74988L18.9975 11.2499C18.9975 11.8022 18.5498 12.2499 17.9975 12.2499Z\"><\/path>\n  <path d=\"M13.7475 16.2499L18.2475 16.2499\"><\/path>\n  <path d=\"M13.7475 19.2499L18.2475 19.2499\"><\/path>\n<\/svg><\/button><textarea>while (true) {\n    $logEntry = $redis-&gt;lpop('log_queue');\n    if ($logEntry) {\n        file_put_contents('logs\/database.log', $logEntry . PHP_EOL, FILE_APPEND | LOCK_EX);\n    } else {\n        usleep(100000); \/\/ Wait if queue is empty\n    }\n}<\/textarea>\n<\/div><code>while (true) {\n    $logEntry = $redis-&gt;lpop('log_queue');\n    if ($logEntry) {\n        file_put_contents('logs\/database.log', $logEntry . PHP_EOL, FILE_APPEND | LOCK_EX);\n    } else {\n        usleep(100000); \/\/ Wait if queue is empty\n    }\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<h4 class=\"wp-block-heading\" id=\"the-impact-of-these-improvements\"><strong>The Impact of These Improvements<\/strong><\/h4>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\">With these enhancements, our database class has become:<\/p>\n\n\n<ul class=\"wp-block-list wp-block-list\">\n<li>\n<strong>More Scalable:<\/strong> <br>Exponential backoff and Redis integration handle high-concurrency scenarios efficiently.<\/li>\n\n\n\n<li>\n<strong>Faster:<\/strong> <br>Query caching reduces response times significantly.<\/li>\n\n\n\n<li>\n<strong>Resilient:<\/strong> <br>Retry mechanisms and asynchronous logging improve reliability under heavy load.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\">The evolution of our database class reflects a commitment to building resilient, high-performance systems. By addressing real-world challenges with features like exponential backoff, caching, and asynchronous logging, we&rsquo;ve created a tool that&rsquo;s ready for production environments at scale.<\/p>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\">What are your thoughts on these improvements? Have you implemented similar techniques in your systems? Let us know in the comments or reach out directly!<\/p>\n\n\n<p class=\"wp-block-paragraph wp-block-paragraph\" style=\"\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a previous blog, we showcased a robust database class designed to streamline database interactions and handle common issues like deadlocks gracefully. While the original version was reliable, we&#8217;ve since implemented significant improvements to address real-world challenges, particularly in high-concurrency scenarios. Today, we&#8217;re excited to introduce exponential backoff in our retry mechanism, enhanced logging, and &hellip;<\/p>\n","protected":false},"author":1,"featured_media":482,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40,52],"tags":[41,26,25],"class_list":["post-481","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database","category-programming","tag-databases","tag-galera","tag-high-available"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Evolving Our Database Class \u2013 Introducing Exponential Backoff and Enhanced Performance - SystemDeveloper.NL<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Evolving Our Database Class \u2013 Introducing Exponential Backoff and Enhanced Performance - SystemDeveloper.NL\" \/>\n<meta property=\"og:description\" content=\"In a previous blog, we showcased a robust database class designed to streamline database interactions and handle common issues like deadlocks gracefully. While the original version was reliable, we&#8217;ve since implemented significant improvements to address real-world challenges, particularly in high-concurrency scenarios. Today, we&#8217;re excited to introduce exponential backoff in our retry mechanism, enhanced logging, and &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/\" \/>\n<meta property=\"og:site_name\" content=\"SystemDeveloper.NL\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/quan.tora.16\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-06T19:02:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-12-06T19:07:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.systemdeveloper.nl\/tech\/wp-content\/uploads\/2024\/12\/96d407a2-2dba-49b6-bd19-9f643c12b454-e1733511742534.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"John Timmer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"John Timmer\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/\"},\"author\":{\"name\":\"John Timmer\",\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/#\\\/schema\\\/person\\\/5760c2ed5300c56d8ef01dfb00a9763b\"},\"headline\":\"Evolving Our Database Class \u2013 Introducing Exponential Backoff and Enhanced Performance\",\"datePublished\":\"2024-12-06T19:02:29+00:00\",\"dateModified\":\"2024-12-06T19:07:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/\"},\"wordCount\":561,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/96d407a2-2dba-49b6-bd19-9f643c12b454-e1733511742534.webp\",\"keywords\":[\"Databases\",\"Galera\",\"High Available\"],\"articleSection\":[\"Database\",\"Programming\"],\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/\",\"url\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/\",\"name\":\"Evolving Our Database Class \u2013 Introducing Exponential Backoff and Enhanced Performance - SystemDeveloper.NL\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/96d407a2-2dba-49b6-bd19-9f643c12b454-e1733511742534.webp\",\"datePublished\":\"2024-12-06T19:02:29+00:00\",\"dateModified\":\"2024-12-06T19:07:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/#breadcrumb\"},\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/96d407a2-2dba-49b6-bd19-9f643c12b454-e1733511742534.webp\",\"contentUrl\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/96d407a2-2dba-49b6-bd19-9f643c12b454-e1733511742534.webp\",\"width\":1024,\"height\":768},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Evolving Our Database Class \u2013 Introducing Exponential Backoff and Enhanced Performance\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/#website\",\"url\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/\",\"name\":\"www.systemdeveloper.nl\",\"description\":\"NextGen IT\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/#organization\",\"name\":\"www.systemdeveloper.nl\",\"url\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/qt-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/qt-logo.png\",\"width\":1346,\"height\":1230,\"caption\":\"www.systemdeveloper.nl\"},\"image\":{\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/quan.tora.16\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/#\\\/schema\\\/person\\\/5760c2ed5300c56d8ef01dfb00a9763b\",\"name\":\"John Timmer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/cropped-D6E27035-6864-4270-8D72-0D8C0C59F370-96x96.jpeg\",\"url\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/cropped-D6E27035-6864-4270-8D72-0D8C0C59F370-96x96.jpeg\",\"contentUrl\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/cropped-D6E27035-6864-4270-8D72-0D8C0C59F370-96x96.jpeg\",\"caption\":\"John Timmer\"},\"sameAs\":[\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\"],\"url\":\"https:\\\/\\\/www.systemdeveloper.nl\\\/tech\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Evolving Our Database Class \u2013 Introducing Exponential Backoff and Enhanced Performance - SystemDeveloper.NL","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/","og_locale":"en_US","og_type":"article","og_title":"Evolving Our Database Class \u2013 Introducing Exponential Backoff and Enhanced Performance - SystemDeveloper.NL","og_description":"In a previous blog, we showcased a robust database class designed to streamline database interactions and handle common issues like deadlocks gracefully. While the original version was reliable, we&#8217;ve since implemented significant improvements to address real-world challenges, particularly in high-concurrency scenarios. Today, we&#8217;re excited to introduce exponential backoff in our retry mechanism, enhanced logging, and &hellip;","og_url":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/","og_site_name":"SystemDeveloper.NL","article_publisher":"https:\/\/www.facebook.com\/quan.tora.16","article_published_time":"2024-12-06T19:02:29+00:00","article_modified_time":"2024-12-06T19:07:12+00:00","og_image":[{"width":1024,"height":768,"url":"https:\/\/www.systemdeveloper.nl\/tech\/wp-content\/uploads\/2024\/12\/96d407a2-2dba-49b6-bd19-9f643c12b454-e1733511742534.webp","type":"image\/webp"}],"author":"John Timmer","twitter_card":"summary_large_image","twitter_misc":{"Written by":"John Timmer","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/#article","isPartOf":{"@id":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/"},"author":{"name":"John Timmer","@id":"https:\/\/www.systemdeveloper.nl\/tech\/#\/schema\/person\/5760c2ed5300c56d8ef01dfb00a9763b"},"headline":"Evolving Our Database Class \u2013 Introducing Exponential Backoff and Enhanced Performance","datePublished":"2024-12-06T19:02:29+00:00","dateModified":"2024-12-06T19:07:12+00:00","mainEntityOfPage":{"@id":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/"},"wordCount":561,"commentCount":0,"publisher":{"@id":"https:\/\/www.systemdeveloper.nl\/tech\/#organization"},"image":{"@id":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/#primaryimage"},"thumbnailUrl":"https:\/\/www.systemdeveloper.nl\/tech\/wp-content\/uploads\/2024\/12\/96d407a2-2dba-49b6-bd19-9f643c12b454-e1733511742534.webp","keywords":["Databases","Galera","High Available"],"articleSection":["Database","Programming"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/","url":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/","name":"Evolving Our Database Class \u2013 Introducing Exponential Backoff and Enhanced Performance - SystemDeveloper.NL","isPartOf":{"@id":"https:\/\/www.systemdeveloper.nl\/tech\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/#primaryimage"},"image":{"@id":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/#primaryimage"},"thumbnailUrl":"https:\/\/www.systemdeveloper.nl\/tech\/wp-content\/uploads\/2024\/12\/96d407a2-2dba-49b6-bd19-9f643c12b454-e1733511742534.webp","datePublished":"2024-12-06T19:02:29+00:00","dateModified":"2024-12-06T19:07:12+00:00","breadcrumb":{"@id":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/#primaryimage","url":"https:\/\/www.systemdeveloper.nl\/tech\/wp-content\/uploads\/2024\/12\/96d407a2-2dba-49b6-bd19-9f643c12b454-e1733511742534.webp","contentUrl":"https:\/\/www.systemdeveloper.nl\/tech\/wp-content\/uploads\/2024\/12\/96d407a2-2dba-49b6-bd19-9f643c12b454-e1733511742534.webp","width":1024,"height":768},{"@type":"BreadcrumbList","@id":"https:\/\/www.systemdeveloper.nl\/tech\/evolving-our-database-class-introducing-exponential-backoff-and-enhanced-performance\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.systemdeveloper.nl\/tech\/"},{"@type":"ListItem","position":2,"name":"Evolving Our Database Class \u2013 Introducing Exponential Backoff and Enhanced Performance"}]},{"@type":"WebSite","@id":"https:\/\/www.systemdeveloper.nl\/tech\/#website","url":"https:\/\/www.systemdeveloper.nl\/tech\/","name":"www.systemdeveloper.nl","description":"NextGen IT","publisher":{"@id":"https:\/\/www.systemdeveloper.nl\/tech\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.systemdeveloper.nl\/tech\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/www.systemdeveloper.nl\/tech\/#organization","name":"www.systemdeveloper.nl","url":"https:\/\/www.systemdeveloper.nl\/tech\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/www.systemdeveloper.nl\/tech\/#\/schema\/logo\/image\/","url":"https:\/\/www.systemdeveloper.nl\/tech\/wp-content\/uploads\/2024\/11\/qt-logo.png","contentUrl":"https:\/\/www.systemdeveloper.nl\/tech\/wp-content\/uploads\/2024\/11\/qt-logo.png","width":1346,"height":1230,"caption":"www.systemdeveloper.nl"},"image":{"@id":"https:\/\/www.systemdeveloper.nl\/tech\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/quan.tora.16"]},{"@type":"Person","@id":"https:\/\/www.systemdeveloper.nl\/tech\/#\/schema\/person\/5760c2ed5300c56d8ef01dfb00a9763b","name":"John Timmer","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/www.systemdeveloper.nl\/tech\/wp-content\/uploads\/2024\/11\/cropped-D6E27035-6864-4270-8D72-0D8C0C59F370-96x96.jpeg","url":"https:\/\/www.systemdeveloper.nl\/tech\/wp-content\/uploads\/2024\/11\/cropped-D6E27035-6864-4270-8D72-0D8C0C59F370-96x96.jpeg","contentUrl":"https:\/\/www.systemdeveloper.nl\/tech\/wp-content\/uploads\/2024\/11\/cropped-D6E27035-6864-4270-8D72-0D8C0C59F370-96x96.jpeg","caption":"John Timmer"},"sameAs":["https:\/\/www.systemdeveloper.nl\/tech"],"url":"https:\/\/www.systemdeveloper.nl\/tech\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.systemdeveloper.nl\/tech\/wp-json\/wp\/v2\/posts\/481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.systemdeveloper.nl\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.systemdeveloper.nl\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.systemdeveloper.nl\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.systemdeveloper.nl\/tech\/wp-json\/wp\/v2\/comments?post=481"}],"version-history":[{"count":1,"href":"https:\/\/www.systemdeveloper.nl\/tech\/wp-json\/wp\/v2\/posts\/481\/revisions"}],"predecessor-version":[{"id":487,"href":"https:\/\/www.systemdeveloper.nl\/tech\/wp-json\/wp\/v2\/posts\/481\/revisions\/487"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.systemdeveloper.nl\/tech\/wp-json\/wp\/v2\/media\/482"}],"wp:attachment":[{"href":"https:\/\/www.systemdeveloper.nl\/tech\/wp-json\/wp\/v2\/media?parent=481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.systemdeveloper.nl\/tech\/wp-json\/wp\/v2\/categories?post=481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.systemdeveloper.nl\/tech\/wp-json\/wp\/v2\/tags?post=481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}