{"id":46745,"date":"2024-07-25T05:51:17","date_gmt":"2024-07-25T05:51:17","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=46745"},"modified":"2024-08-05T01:23:27","modified_gmt":"2024-08-05T01:23:27","slug":"aws-tutorials-how-to-shutdown-stop-start-opensearch-service-in-aws","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/aws-tutorials-how-to-shutdown-stop-start-opensearch-service-in-aws\/","title":{"rendered":"AWS Tutorials: How to Shutdown (Stop \/ Start) OpenSearch Service in AWS?"},"content":{"rendered":"\n<p>AWS OpenSearch Service does not have a direct \u201cstop\u201d or \u201cshutdown\u201d feature like EC2 instances. However, you can manage costs and reduce resource usage through various strategies, though it is not possible to temporarily stop billing entirely by \u201cshutting down\u201d the service. Here are some options:<\/p>\n\n\n\n<p>Strategies for Reducing Costs Without Direct Shutdown<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-number\">1.<\/span>  Scale Down Resources:\n\u2022   Reduce Instance Count: Decrease the number <span class=\"hljs-keyword\">of<\/span> data nodes or use smaller instance types when the full capacity is not needed.\n\u2022   Adjust Storage: Reduce the allocated storage or <span class=\"hljs-keyword\">switch<\/span> to more cost-effective storage options.\n<span class=\"hljs-number\">2.<\/span>  Auto-Scaling:\n\u2022   Implement auto-scaling policies to automatically adjust the number <span class=\"hljs-keyword\">of<\/span> instances based on traffic and load. This can help manage costs during periods <span class=\"hljs-keyword\">of<\/span> low activity.\n<span class=\"hljs-number\">3.<\/span>  Use Snapshots and Delete Domain:\n\u2022   Backup Data: Take manual snapshots <span class=\"hljs-keyword\">of<\/span> your domain to back up your data.\n\u2022   Delete Domain: Delete the domain when not <span class=\"hljs-keyword\">in<\/span> use and recreate it later using the snapshots. Note that <span class=\"hljs-keyword\">this<\/span> approach involves downtime and the cost <span class=\"hljs-keyword\">of<\/span> snapshots but can reduce costs <span class=\"hljs-keyword\">if<\/span> domains are not needed <span class=\"hljs-keyword\">for<\/span> extended periods.\n<span class=\"hljs-number\">4.<\/span>  Reserved Instances:\n\u2022   Purchase Reserved Instances <span class=\"hljs-keyword\">if<\/span> your usage is predictable to take advantage <span class=\"hljs-keyword\">of<\/span> reduced pricing compared to On-Demand instances.\n<span class=\"hljs-number\">5.<\/span>  Hot\/Warm Architecture:\n\u2022   Implement a hot\/warm architecture to store less frequently accessed data on cheaper, lower-performance nodes.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To manage and optimize your OpenSearch service, you have two primary approaches: Automate Scaling Down and Scaling Up, and taking a full snapshot and recreating an OpenSearch domain. Below are the detailed steps for both approaches.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Approach 1: Automate Scaling Down and Scaling Up<\/h2>\n\n\n\n<p>Automating the scaling of your OpenSearch domain involves adjusting the resources allocated to your domain based on its workload. This helps in maintaining performance during high demand and reducing costs during low demand.<\/p>\n\n\n\n<p>Steps:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-number\">1.<\/span>  Define Metrics and Thresholds:\n\u2022   Determine the key metrics that will trigger scaling actions. Common metrics include CPU utilization, memory usage, and disk space.\n\u2022   <span class=\"hljs-built_in\">Set<\/span> threshold values <span class=\"hljs-keyword\">for<\/span> these metrics to trigger scaling up or down.\n<span class=\"hljs-number\">2.<\/span>  <span class=\"hljs-built_in\">Set<\/span> Up Monitoring:\n\u2022   Use Amazon CloudWatch to monitor the metrics <span class=\"hljs-keyword\">for<\/span> your OpenSearch domain.\n\u2022   Create CloudWatch alarms based on the thresholds you defined.\n<span class=\"hljs-number\">3.<\/span>  Create Scaling Policies:\n\u2022   Configure AWS Auto Scaling policies that define the actions to take when CloudWatch alarms are triggered.\n\u2022   Policies should specify the minimum and maximum number <span class=\"hljs-keyword\">of<\/span> instances and the step size <span class=\"hljs-keyword\">for<\/span> scaling.\n<span class=\"hljs-number\">4.<\/span>  Automate Scaling Actions:\n\u2022   Use AWS Lambda functions to automate the scaling actions. These functions can increase or decrease the number <span class=\"hljs-keyword\">of<\/span> nodes <span class=\"hljs-keyword\">in<\/span> your OpenSearch cluster based on the policies.\n\u2022   Ensure that the Lambda functions are triggered by the CloudWatch alarms.\n<span class=\"hljs-number\">5.<\/span>  Testing and Validation:\n\u2022   Test the scaling policies and automation scripts <span class=\"hljs-keyword\">in<\/span> a staging environment to ensure they work <span class=\"hljs-keyword\">as<\/span> expected.\n\u2022   Monitor the performance and cost impacts <span class=\"hljs-keyword\">in<\/span> the production environment to validate the approach.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Approach 2: Take Full Snapshot &amp; Re-create an OpenSearch Domain<\/h2>\n\n\n\n<p>Taking a full snapshot and recreating the OpenSearch domain is useful for disaster recovery, major version upgrades, or significant changes to your domain configuration.<\/p>\n\n\n\n<p>Steps:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-number\">1.<\/span>  Take a Full Snapshot:\n\u2022   Use the snapshot feature <span class=\"hljs-keyword\">in<\/span> OpenSearch to create a backup <span class=\"hljs-keyword\">of<\/span> your entire domain.\n\u2022   Store the snapshot <span class=\"hljs-keyword\">in<\/span> a secure S3 bucket.\n<span class=\"hljs-number\">2.<\/span>  Create a New OpenSearch Domain:\n\u2022   Define the configuration <span class=\"hljs-keyword\">for<\/span> the <span class=\"hljs-keyword\">new<\/span> OpenSearch domain, including instance types, storage, and network settings.\n\u2022   Ensure that the <span class=\"hljs-keyword\">new<\/span> domain configuration meets your current and future needs.\n<span class=\"hljs-number\">3.<\/span>  Restore <span class=\"hljs-keyword\">from<\/span> Snapshot:\n\u2022   Use the snapshot stored <span class=\"hljs-keyword\">in<\/span> S3 to restore the data to the <span class=\"hljs-keyword\">new<\/span> OpenSearch domain.\n\u2022   Verify that the data has been restored correctly and that the <span class=\"hljs-keyword\">new<\/span> domain is functioning <span class=\"hljs-keyword\">as<\/span> expected.\n<span class=\"hljs-number\">4.<\/span>  Update Endpoint References:\n\u2022   Update your application or services to point to the <span class=\"hljs-keyword\">new<\/span> OpenSearch domain endpoint.\n\u2022   Ensure that there is minimal downtime during the <span class=\"hljs-keyword\">switch<\/span>.\n<span class=\"hljs-number\">5.<\/span>  Test and Validate:\n\u2022   Conduct thorough testing to ensure that the <span class=\"hljs-keyword\">new<\/span> domain performs <span class=\"hljs-keyword\">as<\/span> expected and that all data is intact.\n\u2022   Monitor the <span class=\"hljs-keyword\">new<\/span> domain <span class=\"hljs-keyword\">for<\/span> any performance issues or errors.\n<span class=\"hljs-number\">6.<\/span>  Decommission Old Domain:\n\u2022   Once you are confident that the <span class=\"hljs-keyword\">new<\/span> domain is stable and fully functional, decommission the old OpenSearch domain.\n\u2022   Ensure that you have retained any necessary data or configurations <span class=\"hljs-keyword\">from<\/span> the old domain before decommissioning.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Choosing Between Approaches<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">\u2022   Automate Scaling: Best <span class=\"hljs-keyword\">for<\/span> managing varying workloads and optimizing costs dynamically. Suitable <span class=\"hljs-keyword\">for<\/span> environments <span class=\"hljs-keyword\">with<\/span> fluctuating demand and where downtime is not acceptable.\n\u2022   Snapshot &amp; Recreate: Ideal <span class=\"hljs-keyword\">for<\/span> disaster recovery, major upgrades, or significant changes to the domain setup. Suitable when a planned downtime can be accommodated, and data integrity is crucial.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<script src=\"https:\/\/gist.github.com\/rajeshkumarin\/1b210c8af31d6921d337f6cc2f5c352f.js\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>AWS OpenSearch Service does not have a direct \u201cstop\u201d or \u201cshutdown\u201d feature like EC2 instances. However, you can manage costs and reduce resource usage through various strategies, though it is not possible to temporarily stop billing entirely by \u201cshutting down\u201d the service. Here are some options: Strategies for Reducing Costs Without Direct Shutdown To manage&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-46745","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=46745"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46745\/revisions"}],"predecessor-version":[{"id":46812,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46745\/revisions\/46812"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=46745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=46745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=46745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}