{"id":3388,"date":"2017-04-30T02:29:37","date_gmt":"2017-04-30T09:29:37","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=3388"},"modified":"2023-06-19T02:30:34","modified_gmt":"2023-06-19T09:30:34","slug":"gsi-replicas-rebalancing","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/","title":{"rendered":"New to Couchbase Server 5.0: GSI replicas and rebalancing"},"content":{"rendered":"<p>Couchbase Server 4.0 introduced Global Secondary Indexes (GSI) to support the N1QL query engine. \u00a0Now, with Couchbase Server 5.0 (<a href=\"https:\/\/www.couchbase.com\/blog\/couchbase-5-0-april-2017-developer-build\/\">as of the April developer build<\/a>), we have added the ability to automatically replicate and rebalance these indexes.<\/p>\n<p>At first, GSIs were managed very manually:<\/p>\n<ul>\n<li>To ensure High Availability, the end-user manually configured multiple indexes with the same definition and specified which nodes of the cluster they should be deployed on. \u00a0If one node failed, the end-user had\u00a0to manually re-create the index that was lost.<\/li>\n<li>When adding and removing nodes either for scaling out, upgrading or after a failure, the end-user had\u00a0to manually move and recreate the indexes on the nodes that were coming and going.<\/li>\n<\/ul>\n<p>I&#8217;m extremely proud to report that both of these key operational tasks are now automatically built-in to Couchbase Server and I will walk you through them here.<\/p>\n<h2>GSI Replication<\/h2>\n<p>One of the most frequent requests that we heard from customers after the introduction of GSIs in 4.0 was for automatic management of replication: &#8220;I just want to tell you how many replicas and have you figure it out&#8221;<\/p>\n<p>Now you can:<\/p>\n<pre class=\"\"><code>CREATE INDEX `idx_airportname` ON `travel-sample`(`airportname`) WITH {\"num_replica\":1};<\/code>\r\n<\/pre>\n<p>With one simple command, Couchbase will:<\/p>\n<ul>\n<li>Create two identical indexes<\/li>\n<li>Deploy and build those indexes on separate nodes<\/li>\n<li>Honor the Rack-Zone Awareness configuration<\/li>\n<\/ul>\n<p>If not enough nodes are available, you are\u00a0quickly presented with an error:<\/p>\n<pre><code>[\r\n  {\r\n    \"code\": 5000,\r\n    \"msg\": \"GSI CreateIndex() - cause: Fails to create index.  There are not enough indexer nodes to create index with replica count of 2\",\r\n    \"query_from_user\": \"CREATE INDEX `idx_airportname` ON `travel-sample`(`airportname`) WITH {\\\"num_replica\\\":2};\"\r\n  }\r\n]<\/code><\/pre>\n<p>Pretty cool eh?<\/p>\n<p>When using &#8220;num_replica&#8221;, you are relying on Couchbase to determine the proper index layout within the cluster. \u00a0For even more fine-grained control, specify the exact nodes you wish a single index to be replicated across:<\/p>\n<pre class=\"\"><code>CREATE INDEX `idx_airportname` ON `travel-sample`(`airportname`) WITH {\"nodes\":[\"ec2-35-167-251-49.us-west-2.compute.amazonaws.com:8091\", \"ec2-54-69-121-55.us-west-2.compute.amazonaws.com:8091\"]};<\/code>\r\n<\/pre>\n<p>Voila!<\/p>\n<p>These\u00a0indexes will now be automatically load balanced by the query engine and any failure (so long as at least one matching index remains) will not cause any disruption to the queries.<\/p>\n<h2>GSI Rebalancing<\/h2>\n<p>It&#8217;s not enough just to have automatic replica\u00a0<em>creation<\/em>, we also needed to add automatic management in the form of rebalancing.<\/p>\n<p>Again, as of the April developer build of Couchbase Server 5.0, the index service is now &#8220;rebalance aware&#8221;:<\/p>\n<ul>\n<li>When\u00a0an index node is removed from the cluster, its indexes will be redistributed to the remaining nodes automatically. \u00a0However, adding a new index node to the cluster will not cause the indexes to be re-distributed. \u00a0This is by design to prevent excess movement of indexes and also to preserve the placement that an administrator may have specified. \u00a0This redistribution is something that might be added in a later release if needed.<\/li>\n<li>If an index node fails and is replaced, the appropriate replicas will be re-created. \u00a0Similarly, those index replicas are\u00a0re-created on the remaining nodes of a cluster if a rebalance is performed without replacing the failed node.<\/li>\n<\/ul>\n<p>I encourage you to give this all a try and find that it &#8220;just works&#8221;! \u00a0<a href=\"https:\/\/www.couchbase.com\/downloads\/\">Click here to download Couchbase Server.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Couchbase Server 4.0 introduced Global Secondary Indexes (GSI) to support the N1QL query engine. \u00a0Now, with Couchbase Server 5.0 (as of the April developer build), we have added the ability to automatically replicate and rebalance these indexes. At first, GSIs [&hellip;]<\/p>\n","protected":false},"author":24,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1816,1812],"tags":[1971,1695],"ppma_author":[8969],"class_list":["post-3388","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-couchbase-server","category-n1ql-query","tag-couchbase-5-0","tag-gsi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.8 (Yoast SEO v25.8) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>New to Couchbase Server 5.0: GSI replicas and rebalancing - The Couchbase Blog<\/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.couchbase.com\/blog\/gsi-replicas-rebalancing\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"New to Couchbase Server 5.0: GSI replicas and rebalancing\" \/>\n<meta property=\"og:description\" content=\"Couchbase Server 4.0 introduced Global Secondary Indexes (GSI) to support the N1QL query engine. \u00a0Now, with Couchbase Server 5.0 (as of the April developer build), we have added the ability to automatically replicate and rebalance these indexes. At first, GSIs [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-04-30T09:29:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-19T09:30:34+00:00\" \/>\n<meta name=\"author\" content=\"Perry Krug\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Perry Krug\" \/>\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\/blog\/gsi-replicas-rebalancing\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/\"},\"author\":{\"name\":\"Perry Krug\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/d75b855801e89467ae2cfe0caef39a15\"},\"headline\":\"New to Couchbase Server 5.0: GSI replicas and rebalancing\",\"datePublished\":\"2017-04-30T09:29:37+00:00\",\"dateModified\":\"2023-06-19T09:30:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/\"},\"wordCount\":474,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"keywords\":[\"Couchbase 5.0\",\"GSI\"],\"articleSection\":[\"Couchbase Server\",\"SQL++ \/ N1QL Query\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/\",\"name\":\"New to Couchbase Server 5.0: GSI replicas and rebalancing - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2017-04-30T09:29:37+00:00\",\"dateModified\":\"2023-06-19T09:30:34+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"New to Couchbase Server 5.0: GSI replicas and rebalancing\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/d75b855801e89467ae2cfe0caef39a15\",\"name\":\"Perry Krug\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/07fdef12afbaed73ed2879a6d989ae12\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d526d9acbd39623c0a9c0443617ab51bc75b0d8118706229ff946cea1a223257?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d526d9acbd39623c0a9c0443617ab51bc75b0d8118706229ff946cea1a223257?s=96&d=mm&r=g\",\"caption\":\"Perry Krug\"},\"description\":\"Perry Krug is the Head of Developer Experience at Couchbase. He has been with Couchbase for over 13 years and has been working with high-performance caching and database systems for over 17.\",\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/perry-krug\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"New to Couchbase Server 5.0: GSI replicas and rebalancing - The Couchbase Blog","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\/blog\/gsi-replicas-rebalancing\/","og_locale":"en_US","og_type":"article","og_title":"New to Couchbase Server 5.0: GSI replicas and rebalancing","og_description":"Couchbase Server 4.0 introduced Global Secondary Indexes (GSI) to support the N1QL query engine. \u00a0Now, with Couchbase Server 5.0 (as of the April developer build), we have added the ability to automatically replicate and rebalance these indexes. At first, GSIs [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/","og_site_name":"The Couchbase Blog","article_published_time":"2017-04-30T09:29:37+00:00","article_modified_time":"2023-06-19T09:30:34+00:00","author":"Perry Krug","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Perry Krug","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/"},"author":{"name":"Perry Krug","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/d75b855801e89467ae2cfe0caef39a15"},"headline":"New to Couchbase Server 5.0: GSI replicas and rebalancing","datePublished":"2017-04-30T09:29:37+00:00","dateModified":"2023-06-19T09:30:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/"},"wordCount":474,"commentCount":7,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","keywords":["Couchbase 5.0","GSI"],"articleSection":["Couchbase Server","SQL++ \/ N1QL Query"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/","url":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/","name":"New to Couchbase Server 5.0: GSI replicas and rebalancing - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2017-04-30T09:29:37+00:00","dateModified":"2023-06-19T09:30:34+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/gsi-replicas-rebalancing\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"New to Couchbase Server 5.0: GSI replicas and rebalancing"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/d75b855801e89467ae2cfe0caef39a15","name":"Perry Krug","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/07fdef12afbaed73ed2879a6d989ae12","url":"https:\/\/secure.gravatar.com\/avatar\/d526d9acbd39623c0a9c0443617ab51bc75b0d8118706229ff946cea1a223257?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d526d9acbd39623c0a9c0443617ab51bc75b0d8118706229ff946cea1a223257?s=96&d=mm&r=g","caption":"Perry Krug"},"description":"Perry Krug is the Head of Developer Experience at Couchbase. He has been with Couchbase for over 13 years and has been working with high-performance caching and database systems for over 17.","url":"https:\/\/www.couchbase.com\/blog\/author\/perry-krug\/"}]}},"authors":[{"term_id":8969,"user_id":24,"is_guest":0,"slug":"perry-krug","display_name":"Perry Krug","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/d526d9acbd39623c0a9c0443617ab51bc75b0d8118706229ff946cea1a223257?s=96&d=mm&r=g","author_category":"","last_name":"Krug","first_name":"Perry","job_title":"","user_url":"","description":"Perry Krug is an Architect in the Office of the CTO focused on customer solutions. He has been with Couchbase for over 8 years and has been working with high-performance caching and database systems for over 12 years."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/3388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=3388"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/3388\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=3388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=3388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=3388"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=3388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}