Skip to content

replacing OpenSearch Serverless with a dedicated instance?

0

Hi all,

I am making a chatbot using this GitHub repo https://github.com/aws-samples/amazon-bedrock-samples/tree/main/rag-solutions/contextual-chatbot-using-knowledgebase. My chatbot will store about 5GB of company data in an S3 Bucket. The chatbot will be on my website which customers can ask questions to, and the chatbot will use the data stored in the S3 Bucket to answer the questions.

The chatbot uses AWS Bedrock, AWS Lambda, AWS CloudFormation, AWS S3, and AWS OpenSearch Serverless.

I have calculated the approximate total monthly cost for all of these services, which is around 1200USD per month. The largest cost comes from AWS OpenSearch Serverless, which is around 700USD. I read online that it would be more cost effective and cheaper to use a dedicated instance instead of AWS OpenSearch Serverless.

My question then is:

  1. How can I change the code in the GitHub repo to use a dedicated instance instead of AWS OpenSearch Serverless?
  2. I've had a brief look at calculating the EC2 monthly costs using the AWS Pricing Calculator, and the cost comes to something ridiculous like just under 2000USD/month. Have I done something wrong? Why is it so much more expensive than OSServerless? I don't completely understand all of the entry fields that you have to complete in the calculator for EC2, but I think I kind of understand it given my research. I calculated the EC2 cost in the N Virginia region, for 2 dedicated instances per month, on a Linux operating system, and constant usage for 24 hours per day (as I don't want my chatbot to shut off for some hours of the day?) and the c5.xlarge instance family. I selected the on-demand option, as I want to only pay for what I use each month.
  3. If someone queries my chatbot, and the chatbot replies, will that count as "data transfer" out of the EC2? As the chatbot will be answering the questions asked using the data stored in the S3 Bucket.

Sorry for all the questions. I just wish AWS was easier to understand as a beginner!

Thank you.

1 Answer
2
Accepted Answer

1. Understanding the Cost Comparison

AWS OpenSearch Serverless is a managed service with autoscaling, and you pay based on the resources consumed. The $700/month is likely due to the service’s elasticity and managed nature, where AWS handles scaling, backups, and availability. Dedicated EC2 Instance involves managing your own OpenSearch cluster, meaning you're responsible for the instance's uptime, scaling, and maintenance. While EC2 instances might seem cheaper per hour, the costs can add up when you factor in 24/7 uptime, EBS storage, data transfer, and operational overhead.

2. Setting Up OpenSearch on EC2

To replace OpenSearch Serverless with a dedicated instance, you'll need to deploy an OpenSearch cluster on EC2. Here's how you can proceed:

a. Select EC2 Instance Types

Choose Instance Type: Typically, you'd use an instance type optimized for compute and memory, like r5.large, r5.xlarge, or m5.large.

Instance Count: For redundancy, you'll need at least two instances (a master node and a data node) in a production setup.

b. Set Up OpenSearch

Launch EC2 Instances: Launch EC2 instances in your desired region with an appropriate AMI (Amazon Linux 2 is common).

Install OpenSearch: SSH into your instances and install OpenSearch using RPMs or via a Docker container.

Configure Cluster: Set up the OpenSearch cluster, ensuring that your nodes are connected and properly configured for replication and redundancy.

c. Networking and Security

VPC Configuration: Ensure your EC2 instances are within a VPC and have security groups set up to allow access only from trusted sources.

**Data Transfer: ** Yes, querying your chatbot and receiving responses will count as data transfer, especially if the responses are served from the EC2 instance. Ensure your security groups allow HTTP/HTTPS traffic.

3. Modifying the Code in the GitHub Repo

You'll need to modify the codebase to point to your new OpenSearch cluster running on EC2. Specifically:

**Endpoint Configuration: ** Replace the OpenSearch Serverless endpoint with the endpoint of your OpenSearch instance.

Authentication: If you're using IAM roles or credentials, you might need to adjust them since you're now responsible for managing access.

Scaling and Maintenance: Monitor your instances and scale them manually if needed. You might also need to set up alarms in CloudWatch to handle resource usage spikes.

4. Understanding EC2 Costs

**Instance Hours: ** Your calculation might seem high because you’re using on-demand pricing. Reserved instances or spot instances can offer significant savings, but they come with trade-offs (e.g., commitment or potential interruptions).

**Data Transfer Costs: **Outbound data from EC2 to the internet or other AWS services incurs costs. If your chatbot is serving a lot of data or has high traffic, this can be significant.

Storage Costs: EBS volumes attached to your EC2 instances also add to your costs.

5. Optimizing Costs

Right-Sizing Instances: Ensure you choose the right instance size for your workload. Using too large an instance can waste resources. Reserved Instances: Consider reserving instances for 1 or 3 years if you expect to run the service long-term. This can reduce costs by up to 75% compared to on-demand.

**Spot Instances: ** For non-critical workloads, spot instances can be a cost-effective option, but they come with the risk of being terminated by AWS when the capacity is needed.

EXPERT
answered a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
  • Thank you! (:

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.