{"id":20512,"date":"2025-04-17T08:48:18","date_gmt":"2025-04-17T15:48:18","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/high-availability-automatic-failover-app-services\/"},"modified":"2025-04-17T08:48:18","modified_gmt":"2025-04-17T15:48:18","slug":"high-availability-automatic-failover-app-services","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/","title":{"rendered":"Ensuring High Availability with Automatic Failover for App Services"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><span>In modern applications, continuous connectivity is key\u2014especially for mobile apps relying on backend services. In this blog, we\u2019ll walk through a Python-based solution that monitors the health of your app service servers and automatically fails over to a secondary server if needed. This sample code uses HTTP health checks and WebSocket connection endpoints to ensure that your application always connects to a healthy service.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Overview<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><span>The solution involves two types of endpoints:<\/span><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><b>Health check URLs<\/b>\n<ul>\n<li aria-level=\"2\"><span>These endpoints (e.g., <\/span><span><code>https:\/\/...\/_ping<\/code><\/span><span>) are polled using <em>HTTP <\/em><\/span><em><span>HEAD<\/span><\/em><span> requests.<\/span><\/li>\n<li aria-level=\"2\"><span>They determine if the app service server is healthy.<\/span><\/li>\n<\/ul>\n<\/li>\n\n\n<li><b>Connection endpoints<\/b>\n<ul>\n<li aria-level=\"2\"><span>These are the WebSocket URLs (e.g., <\/span><span><code>wss:\/\/...\/primary<\/code><\/span><span>) that your application uses to interact with the backend.<\/span><\/li>\n<li aria-level=\"2\"><span>The active connection endpoint is updated based on the health check results.<\/span><\/li>\n<\/ul>\n<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><span>If the primary server\u2019s health check fails consecutively, the failover logic will switch the application\u2019s connection to the secondary server.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The code in detail<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><span>Below is the complete code with inline comments and detailed explanations:<\/span><\/p>\n\n\n<p>[crayon nums=&#8221;false&#8221; lang=&#8221;python&#8221; decode=&#8221;true&#8221;]import logging<br \/>\nimport threading<br \/>\nimport requests<br \/>\nfrom time import sleep<\/p>\n<p># Configure logging to show time-stamped messages at INFO level.<br \/>\nlogging.basicConfig(level=logging.INFO, format=&#8217;%(asctime)s %(levelname)s: %(message)s&#8217;)<\/p>\n<p># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n# Health Check URLs (App Service Servers)<br \/>\n# &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n# These URLs are used for health checking the servers by sending HEAD requests.<br \/>\nhealth_check_urls = {<br \/>\n\u00a0\u00a0\u00a0\u00a0&#8220;primary&#8221;: &#8220;https:\/\/XXXXXXXXXXXXXX.apps.cloud.couchbase.com:4984\/_ping&#8221;,<br \/>\n\u00a0\u00a0\u00a0\u00a0&#8220;secondary&#8221;: &#8220;https:\/\/XXXXXXXXXXXXXX.apps.cloud.couchbase.com:4984\/_ping&#8221;<br \/>\n}<\/p>\n<p># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n# Connection Endpoints (WebSocket URLs)<br \/>\n# &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n# These endpoints are what your application actually uses for connections.<br \/>\nconnection_urls = {<br \/>\n\u00a0\u00a0\u00a0\u00a0&#8220;primary&#8221;: &#8220;wss:\/\/XXXXXXXXXXXXXX.apps.cloud.couchbase.com:4984\/primary&#8221;,<br \/>\n\u00a0\u00a0\u00a0\u00a0&#8220;secondary&#8221;: &#8220;wss:\/\/XXXXXXXXXXXXXX.apps.cloud.ucouchbase.com:4984\/secondary&#8221;<br \/>\n}<\/p>\n<p># The variable `active_cluster` tracks which server is currently active.<br \/>\nactive_cluster = &#8220;primary&#8221;<\/p>\n<p># This variable holds the actual WebSocket URL used by your application.<br \/>\nactive_connection_url = connection_urls[active_cluster]<\/p>\n<p>def is_cluster_healthy(url):<br \/>\n\u00a0\u00a0\u00a0\u00a0&#8220;&#8221;&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0Perform a health check using a HEAD request against the provided URL.<br \/>\n\u00a0\u00a0\u00a0\u00a0Returns True if the response status is 200; otherwise, returns False.<br \/>\n\u00a0\u00a0\u00a0\u00a0Logs the status code and headers for troubleshooting.<br \/>\n\u00a0\u00a0\u00a0\u00a0&#8220;&#8221;&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0try:<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0response = requests.head(url, timeout=5)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.info(f&#8221;Health Check Response for {url}&#8221;)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.info(f&#8221;\u00a0 Status Code: {response.status_code}&#8221;)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.info(&#8221;\u00a0 Headers:&#8221;)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0for header, value in response.headers.items():<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.info(f&#8221;\u00a0 \u00a0 {header}: {value}&#8221;)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if response.status_code == 200:<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.info(f&#8221;{url} is healthy!&#8221;)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return True<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else:<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.warning(f&#8221;{url} might be unhealthy or unreachable.&#8221;)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return False<br \/>\n\u00a0\u00a0\u00a0\u00a0except requests.exceptions.RequestException as e:<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.error(f&#8221;Health check failed for {url}: {e}&#8221;)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return False<\/p>\n<p>def health_check_worker():<br \/>\n\u00a0\u00a0\u00a0\u00a0&#8220;&#8221;&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0A background worker that checks the health of the active server every 3 seconds.<br \/>\n\u00a0\u00a0\u00a0\u00a0If the active server fails health checks for more than 9 consecutive times,<br \/>\n\u00a0\u00a0\u00a0\u00a0the worker attempts to switch to the other server.<br \/>\n\u00a0\u00a0\u00a0\u00a0&#8220;&#8221;&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0global active_cluster<br \/>\n\u00a0\u00a0\u00a0\u00a0global active_connection_url<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0consecutive_failures = 0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0while True:<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sleep(3)\u00a0 # Wait 3 seconds between checks.<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Use the HTTP health check endpoint for the active cluster.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0current_health_url = health_check_urls[active_cluster]<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.info(f&#8221;Health check: Checking {active_cluster} at {current_health_url}&#8230;&#8221;)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if is_cluster_healthy(current_health_url):<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0consecutive_failures = 0\u00a0 # Reset counter if healthy.<br \/>\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else:<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0consecutive_failures += 1<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.warning(f&#8221;{active_cluster} health check failed {consecutive_failures} time(s).&#8221;)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# If failures exceed 9 consecutive attempts, try to fail over.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if consecutive_failures &gt; 9:<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.error(f&#8221;{active_cluster} is considered down. Attempting to fail over&#8230;&#8221;)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Determine the new active cluster.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0new_cluster = &#8220;secondary&#8221; if active_cluster == &#8220;primary&#8221; else &#8220;primary&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0new_health_url = health_check_urls[new_cluster]<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Check if the new cluster is healthy.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if is_cluster_healthy(new_health_url):<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0active_cluster = new_cluster<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Update the connection endpoint.<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0active_connection_url = connection_urls[new_cluster]<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.warning(f&#8221;Switched active cluster to {new_cluster}.&#8221;)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.warning(f&#8221;New WebSocket connection endpoint: {active_connection_url}&#8221;)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else:<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.critical(&#8220;Both clusters appear to be down!&#8221;)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0consecutive_failures = 0\u00a0 # Reset the failure counter after the attempt.<\/p>\n<p>def main():<br \/>\n\u00a0\u00a0\u00a0\u00a0&#8220;&#8221;&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0Main function to start the health-check worker in a background thread.<br \/>\n\u00a0\u00a0\u00a0\u00a0Keeps the script running indefinitely until interrupted.<br \/>\n\u00a0\u00a0\u00a0\u00a0&#8220;&#8221;&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0thread = threading.Thread(target=health_check_worker, daemon=True)<br \/>\n\u00a0\u00a0\u00a0\u00a0thread.start()<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0logging.info(&#8220;Health check worker started. Press Ctrl+C to exit.&#8221;)<br \/>\n\u00a0\u00a0\u00a0\u00a0logging.info(f&#8221;Application will initially connect to: {active_connection_url}&#8221;)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0try:<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0while True:<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sleep(1)\u00a0 # Main thread remains alive.<br \/>\n\u00a0\u00a0\u00a0\u00a0except KeyboardInterrupt:<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.info(&#8220;Shutting down health check script.&#8221;)<\/p>\n<p>if __name__ == &#8220;__main__&#8221;:<br \/>\n\u00a0\u00a0\u00a0\u00a0main()[\/crayon]<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Key technical points<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><b>Health checks on App Service Servers:<\/b><b><br>\n<\/b><span>The code separates the <\/span><b>health-check endpoints<\/b><span> (used for monitoring) from the <\/span><b>connection endpoints<\/b><span> (used by your application). This allows you to check server health independently while maintaining a stable connection endpoint.<\/span><\/li>\n\n\n<li><b>HTTP HEAD Requests:<\/b><b><br>\n<\/b><span>Using <\/span><span>HEAD<\/span><span> requests to the<\/span><span><code>\/_ping<\/code><\/span><span>\u00a0endpoint minimizes data transfer while still providing status codes and headers for diagnostics.<\/span><\/li>\n\n\n<li><b>Background Thread:<\/b><b><br>\n<\/b><span>The <\/span><span><code>health_check_worker<\/code><\/span><span> runs in its own daemon thread, allowing continuous health monitoring without blocking the main application thread.<\/span><\/li>\n\n\n<li><b>Failover Logic:<\/b>\n<ul>\n<li aria-level=\"2\"><span>A counter (<\/span><span><code>consecutive_failures<\/code><\/span><span>) tracks consecutive failures.<\/span><\/li>\n<li aria-level=\"2\"><span>If the count exceeds a set threshold (9 failures), the script attempts a failover by checking the health of the alternate server.<\/span><\/li>\n<li aria-level=\"2\"><span>Upon a successful health check on the secondary server, the active connection endpoint is updated.<\/span><\/li>\n<\/ul>\n<\/li>\n\n\n<li><b>Logging:<\/b><b><br>\n<\/b><span>Detailed logging provides insights into the health check process, including HTTP response status, headers, and failover events. This aids in troubleshooting and monitoring.<\/span><\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Adapting for your application<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span>You can easily translate and adapt this code to your preferred programming language such as\u00a0 Swift and Kotlin to fit your application\u2019s needs.<\/span><\/li>\n\n\n<li><span>You might integrate this script or logic into your <\/span><b>mobile code<\/b><span> (iOS\/Android) or a <\/span><b>backend service<\/b><span> that updates the <em>active<\/em>\u00a0endpoint.<\/span><\/li>\n\n\n<li><span>If you are on iOS or Android, consider how often and where you run this code. For example, background tasks or push notifications can trigger health checks in a mobile context.<\/span><\/li>\n\n\n<li><span>If you have a microservice architecture, you might run this failover logic in a small service that exposes a <em>current active URL<\/em>\u00a0to the mobile apps, so they always connect to the correct WSS endpoint.<\/span><\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><span>This sample code provides a straightforward yet powerful mechanism for ensuring high availability in applications by automatically failing over to a backup server when the primary becomes unreachable. By separating the health checks from the connection endpoints, the application ensures that it always connects to a healthy server via WebSocket.<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span>In a production environment, you may need to adapt and extend the logic to suit your specific requirements, network conditions, and security policies.<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span>Implementing this logic in your mobile application or backend service can greatly improve uptime and resilience, ensuring your users remain connected even during unexpected service interruptions.<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In modern applications, continuous connectivity is key\u2014especially for mobile apps relying on backend services. In this blog, we\u2019ll walk through a Python-based solution that monitors the health of your app service servers and automatically fails over to a secondary server if needed. This sample code uses HTTP health checks and WebSocket connection endpoints to ensure [&hellip;]<\/p>\n","protected":false},"author":85152,"featured_media":20511,"comment_status":"open","ping_status":"open","sticky":false,"template":"single-post","format":"standard","meta":{"_acf_changed":false,"_acf":"","inline_featured_image":false,"footnotes":"","_ppma_block_editor_authors":""},"categories":[1337,821,992,1095],"tags":[1204,1586],"ppma_author":[1516,1624],"class_list":["post-20512","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-app-services","category-best-practices-and-tutorials","category-cloud","category-python","tag-high-availability","tag-websocket"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.9 (Yoast SEO v28.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Ensuring High Availability with Automatic Failover for App Services<\/title>\n<meta name=\"description\" content=\"Boost app reliability with Python-based automatic failover. Monitor server health and switch WebSocket connections seamlessly to keep users connected.\" \/>\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.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ensuring High Availability with Automatic Failover for App Services\" \/>\n<meta property=\"og:description\" content=\"Boost app reliability with Python-based automatic failover. Monitor server health and switch WebSocket connections seamlessly to keep users connected.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/\" \/>\n<meta property=\"og:site_name\" content=\"Couchbase\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Couchbase\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-17T15:48:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/blog-high-availability-app-services.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1256\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nishant Bhatia - Cloud Architect, Rob Hadaway, Sr. Solutions Architect\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@couchbase\" \/>\n<meta name=\"twitter:site\" content=\"@couchbase\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nishant Bhatia - Cloud Architect\" \/>\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.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/\"},\"author\":{\"name\":\"Nishant Bhatia - Cloud Architect\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/#\\\/schema\\\/person\\\/8fc462ff91958f9764308e95531f5cf5\"},\"headline\":\"Ensuring High Availability with Automatic Failover for App Services\",\"datePublished\":\"2025-04-17T15:48:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/\"},\"wordCount\":1091,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/blog-high-availability-app-services.jpg\",\"keywords\":[\"High Availability\",\"websocket\"],\"articleSection\":[\"App Services\",\"Best Practices and Tutorials\",\"Couchbase Capella\",\"Python\"],\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/\",\"name\":\"Ensuring High Availability with Automatic Failover for App Services\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/blog-high-availability-app-services.jpg\",\"datePublished\":\"2025-04-17T15:48:18+00:00\",\"description\":\"Boost app reliability with Python-based automatic failover. Monitor server health and switch WebSocket connections seamlessly to keep users connected.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/blog-high-availability-app-services.jpg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/blog-high-availability-app-services.jpg\",\"width\":2400,\"height\":1256},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/high-availability-automatic-failover-app-services\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/ko\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ensuring High Availability with Automatic Failover for App Services\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/\",\"name\":\"Couchbase\",\"description\":\"The Operational Data Platform for AI\u2122\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/#organization\"},\"alternateName\":\"Couchbase, Inc.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/#organization\",\"name\":\"Couchbase\",\"alternateName\":\"Couchbase, Inc.\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"width\":1129,\"height\":1129,\"caption\":\"Couchbase\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Couchbase\\\/\",\"https:\\\/\\\/x.com\\\/couchbase\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/CouchbaseServer\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/couchbase\\\/\",\"https:\\\/\\\/github.com\\\/couchbase\\\/\",\"https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Couchbase,_Inc.\"],\"description\":\"Couchbase is a database software company headquartered in San Jose, California, providing an operational data platform for AI used by hundreds of global enterprises.\",\"legalName\":\"Couchbase, Inc.\",\"foundingDate\":\"2011-01-01\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/#\\\/schema\\\/person\\\/8fc462ff91958f9764308e95531f5cf5\",\"name\":\"Nishant Bhatia - Cloud Architect\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7d3d3f6f12724ef9095e97d255b64435e9c6b3df4c0e02d34a569a65138719f2?s=96&d=mm&r=g6b3e33d8e1e728532201181a4b557ec1\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7d3d3f6f12724ef9095e97d255b64435e9c6b3df4c0e02d34a569a65138719f2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7d3d3f6f12724ef9095e97d255b64435e9c6b3df4c0e02d34a569a65138719f2?s=96&d=mm&r=g\",\"caption\":\"Nishant Bhatia - Cloud Architect\"},\"url\":\"https:\\\/\\\/www.couchbase.com\\\/fr\\\/blog\\\/author\\\/nishantbhatia\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Ensuring High Availability with Automatic Failover for App Services","description":"Boost app reliability with Python-based automatic failover. Monitor server health and switch WebSocket connections seamlessly to keep users connected.","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.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/","og_locale":"fr_FR","og_type":"article","og_title":"Ensuring High Availability with Automatic Failover for App Services","og_description":"Boost app reliability with Python-based automatic failover. Monitor server health and switch WebSocket connections seamlessly to keep users connected.","og_url":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/","og_site_name":"Couchbase","article_publisher":"https:\/\/www.facebook.com\/Couchbase\/","article_published_time":"2025-04-17T15:48:18+00:00","og_image":[{"width":2400,"height":1256,"url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/blog-high-availability-app-services.jpg","type":"image\/jpeg"}],"author":"Nishant Bhatia - Cloud Architect, Rob Hadaway, Sr. Solutions Architect","twitter_card":"summary_large_image","twitter_creator":"@couchbase","twitter_site":"@couchbase","twitter_misc":{"Written by":"Nishant Bhatia - Cloud Architect","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/"},"author":{"name":"Nishant Bhatia - Cloud Architect","@id":"https:\/\/www.couchbase.com\/fr\/#\/schema\/person\/8fc462ff91958f9764308e95531f5cf5"},"headline":"Ensuring High Availability with Automatic Failover for App Services","datePublished":"2025-04-17T15:48:18+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/"},"wordCount":1091,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/fr\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/blog-high-availability-app-services.jpg","keywords":["High Availability","websocket"],"articleSection":["App Services","Best Practices and Tutorials","Couchbase Capella","Python"],"inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/","url":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/","name":"Ensuring High Availability with Automatic Failover for App Services","isPartOf":{"@id":"https:\/\/www.couchbase.com\/fr\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/blog-high-availability-app-services.jpg","datePublished":"2025-04-17T15:48:18+00:00","description":"Boost app reliability with Python-based automatic failover. Monitor server health and switch WebSocket connections seamlessly to keep users connected.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/#primaryimage","url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/blog-high-availability-app-services.jpg","contentUrl":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/blog-high-availability-app-services.jpg","width":2400,"height":1256},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/fr\/blog\/high-availability-automatic-failover-app-services\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/ko\/"},{"@type":"ListItem","position":2,"name":"Ensuring High Availability with Automatic Failover for App Services"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/fr\/#website","url":"https:\/\/www.couchbase.com\/fr\/","name":"Couchbase","description":"The Operational Data Platform for AI\u2122","publisher":{"@id":"https:\/\/www.couchbase.com\/fr\/#organization"},"alternateName":"Couchbase, Inc.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/fr\/#organization","name":"Couchbase","alternateName":"Couchbase, Inc.","url":"https:\/\/www.couchbase.com\/fr\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.couchbase.com\/fr\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","contentUrl":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","width":1129,"height":1129,"caption":"Couchbase"},"image":{"@id":"https:\/\/www.couchbase.com\/fr\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Couchbase\/","https:\/\/x.com\/couchbase","https:\/\/www.youtube.com\/c\/CouchbaseServer","https:\/\/www.linkedin.com\/company\/couchbase\/","https:\/\/github.com\/couchbase\/","https:\/\/en.wikipedia.org\/wiki\/Couchbase,_Inc."],"description":"Couchbase est une soci\u00e9t\u00e9 de logiciels de bases de donn\u00e9es dont le si\u00e8ge social est situ\u00e9 \u00e0 San Jose, en Californie, et qui fournit une plateforme op\u00e9rationnelle de donn\u00e9es pour l\u2019IA utilis\u00e9e par des centaines d\u2019entreprises mondiales.","legalName":"Couchbase, Inc.","foundingDate":"2011-01-01"},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/fr\/#\/schema\/person\/8fc462ff91958f9764308e95531f5cf5","name":"Nishant Bhatia - Cloud Architect","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/secure.gravatar.com\/avatar\/7d3d3f6f12724ef9095e97d255b64435e9c6b3df4c0e02d34a569a65138719f2?s=96&d=mm&r=g6b3e33d8e1e728532201181a4b557ec1","url":"https:\/\/secure.gravatar.com\/avatar\/7d3d3f6f12724ef9095e97d255b64435e9c6b3df4c0e02d34a569a65138719f2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7d3d3f6f12724ef9095e97d255b64435e9c6b3df4c0e02d34a569a65138719f2?s=96&d=mm&r=g","caption":"Nishant Bhatia - Cloud Architect"},"url":"https:\/\/www.couchbase.com\/fr\/blog\/author\/nishantbhatia\/"}]}},"authors":[{"term_id":1516,"user_id":85152,"is_guest":0,"slug":"nishantbhatia","display_name":"Nishant Bhatia - Cloud Architect","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/7d3d3f6f12724ef9095e97d255b64435e9c6b3df4c0e02d34a569a65138719f2?s=96&d=mm&r=g","avatar_alt":"","avatar_decorative":"","author_category":"","first_name":"Nishant","last_name":"Bhatia - Cloud Architect","user_url":"","job_title":"","description":""},{"term_id":1624,"user_id":85538,"is_guest":0,"slug":"rob-hadaway","display_name":"Rob Hadaway, Sr. Solutions Architect","avatar_url":{"url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Screenshot-2024-12-20-at-10.48.05-AM-2.png","url2x":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Screenshot-2024-12-20-at-10.48.05-AM-2.png"},"avatar_alt":"","avatar_decorative":"","author_category":"","first_name":"Rob","last_name":"Hadaway, Sr. Solutions Architect","user_url":"","job_title":"","description":"Rob Hadaway is a Senior Solutions Architect at Couchbase, where he specializes in deploying and optimizing scalable database solutions in cloud and on-premises environments. With a strong technical foundation and a passion for problem-solving, Rob has led complex projects involving AWS EKS, Azure, and Kubernetes, ensuring seamless integration and deployment of Couchbase solutions for clients across various industries.\r\n\r\nRob holds a Master of Science in Information Systems and an MBA from the University of Utah. His technical expertise spans a wide range of tools and technologies, including Python, SQL, Terraform, Docker, Kubernetes, and React.js. He is highly credentialed, holding multiple AWS certifications, as well as Kubernetes Administrator and Developer certifications"}],"permalink_manager":null,"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/fr\/wp-json\/wp\/v2\/posts\/20512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/fr\/wp-json\/wp\/v2\/users\/85152"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/fr\/wp-json\/wp\/v2\/comments?post=20512"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/fr\/wp-json\/wp\/v2\/posts\/20512\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/fr\/wp-json\/wp\/v2\/media\/20511"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/fr\/wp-json\/wp\/v2\/media?parent=20512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/fr\/wp-json\/wp\/v2\/categories?post=20512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/fr\/wp-json\/wp\/v2\/tags?post=20512"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/fr\/wp-json\/wp\/v2\/ppma_author?post=20512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}