climatepolicyradar / policy-search

0 stars 1 forks source link

Technical > Move OpenSearch to ec2 instance #128

Closed chrisaballard closed 2 years ago

chrisaballard commented 2 years ago

This should save 40-50% on costs

kdutia commented 2 years ago

Should we use this AWS CloudFormation template for scheduling the EC2 instance? https://aws.amazon.com/solutions/implementations/instance-scheduler/

Alternatively we could manually set up a schedule using AWS Lambda functions https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-cloudwatch/

kdutia commented 2 years ago

Tried using elasticdump to export the index to my local machine so I could re-index it in an EC2 opensearch instance, but it was very slow. I'm going to set up the new opensearch instance and re-run the load instead.

kdutia commented 2 years ago

The new instance has been set up with 1 shard rather than 5 shards which exist on the managed Opensearch instance. From Elasticsearch guidance this seems like the correct thing to do, and may help us reduce our resource usage (each shard has separate overhead).

kdutia commented 2 years ago

I set up a cron job to auto-start opensearch and opensearch-dashboards on reboot. Tested that it works both when restarting the ec2 machine, and stopping it then starting it again.

kdutia commented 2 years ago

Schedule set up on EventBridge for online time 6am-10pm weekdays