Schedule ec2 instance start/stop [closed] - amazon-ec2

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to schedules the time, around which an ec2 instance starts/stops? Is it possible to do it without using cron, aws data pipeline or Lambda? I am trying to create a shell script to automate this task. Please suggest!

Here is a Lambda function which will help you start or stop any instance which have correct tags with start and stop values.
https://gist.github.com/gregarious-repo/b75eb8cb34e9b3644542c81fa7c7c23b
You just need to create new function with proper permission and trigger it by the CloudWatch event which will execute every minute.
Once you have it up and running your instance tags should look like below:

You can use a shell script along with aws cli to get this done.
Incase your ec2 instance is in an auyo scaling setup or if you can place it in an auto scaling setup, you can use the scheduled autoscaling featute as well. You can read about scheduled auto scaling feature here.
http://docs.aws.amazon.com/autoscaling/latest/userguide/schedule_time.html
Note: Auto scaling feature is free to use and coats only for resources that is used up. You may place single instance setups also in auto scaling setup with minimum value set to 0 and use scheduled autoscale feature to get your purpose served.

Related

AWS stopped instances list since last 7 days ,how can get? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 months ago.
Improve this question
List of AWS stopped instances since last 7 days , how do we get please provide solution.
If the event occurred in the last 90 days, then you can get more information about the event using AWS CloudTrail logs. To view the event on CloudTrail, follow these steps:
Open the CloudTrail console.
In the navigation pane, choose Event history.
In the Lookup attributes dropdown menu, select Event name.
For Enter an event name, enter StopInstances if your instance was stopped. Enter RebootInstances if your instance was rebooted.
Enter TerminateInstances if your instance was terminated.
To see more information about an event, choose the event name. On the StopInstances, RebootInstances, or TerminateInstances event details page, you can see the user name of the AWS Identity and Access Management (IAM) user that initiated the event.
Ref:How can I find who stopped, rebooted, or terminated my EC2

Should a Go app panic if it doesn't find external dependencies/services [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
How should a Golang app handle missing external dependencies ?
When a app starts and it doesn't find the database it is supposed to persist the data on, knowing the app is useless in that state, should I panic the app ?
I can otherwise log infinitely something, print to stderr, or use another method to notify, but I'm not sure when to choose each method.
An application that has no access to the external network service should not panic. This should be expected as networks tend to fail. I would wrap the error and pass it further.
Consider the following scenario. You have multiple application servers connected to two database servers. You are upgrading the database servers one at a time. When one is turned off half of your application servers panicked and crashed. You upgrade the second database server and every application server is gone now. Instead, when the database is not available just report an error for instance by sending HTTP status 500. If you have a load balancer it will pass the request to the working applications servers. When the database server is back, the application servers reconnect and continue to work.
Another scenario, you are running an interactive application that processes a database to create a report. The connection is not available. The application panicked and crashed. From the user perspective, it looks like a bug. I would expect a message that connection cannot be established.
In the standard library it is accepted to panic when an internal resource is not available. See template.Must. This means something is wrong with the application itself.
Here's an example from the Go standard library.
Package crypto
import "crypto"
func (Hash) New
func (h Hash) New() hash.Hash
New returns a new hash.Hash calculating the given hash function. New
panics if the hash function is not linked into the binary.

Locust performs very poorly on EC2 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a set of Locust tests that I'm using to test a REST API.
These Locust tests perform extremely poorly when running on EC2 instances.
I developed the tests within a Vagrant VM environment using one VM as the Locust master and one VM as the Locust slave.
Without any effort to tweak the tests my Vagrant dev environment can run up 200 users and generate 50 rps.
But if I run the exact same Locust tests on EC2 and hit the exact same API host the performance is terrible.
Example using a C3.large instance as the master and a C3.2xlarge instance as the slave:
If I specify 300 users Locust will generate a 100 or so at the specified spawn rate then only add new users very slowly. It usually slows to the point where it will never actually create 300 users. And at best I get between 5 - 8 rps.
I'm not sure where to start looking for the discrepancy in performance. Is it the Locust master or the slave? Is it something specific to EC2?
JusDockin, have you checked the file descriptors limit on your instances?
ulimit -n
ulimit -Hn
This may directly affect the number of HTTP requests you're able to generate.
I can easily generate 200 users on a t2.small instance (didn't try to generate more, as Amazon doesn't look too kindly at load testing unless you warn them in advance). That's what I have in my user data:
echo "* soft nofile 40000" >> /etc/security/limits.conf
echo "* hard nofile 40000" >> /etc/security/limits.conf

Queues in Laravel 4.2 [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I am working in a project developed on Laravel 4.2.
I am not able to get the idea about queuing service of laravel. I have read many documents about it but still things are not clear.
Should I compare Queue and cron job ?
when we put a cron job on server, We mention a time when the cron will run. But in the case of queue I could not find the place where time of run is mentioned.
There are some files in App/command directory and code is running on my server but I am helpless to find the time of run OR how to stop these queues.
Please guide me about this problem.
Queue is a service where you add the tasks for later.
Generally you ask other service provider like iron.io to call your application to have the task processes asynchronously and repeat the call if it fails the first time. This allows you to respond to the application user quickly and leave the task to be processed in the background.
If you use local sync driver then task will be done immediately during the same request.

email alerts for Windows Services [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
How can I set an e-mail alert for Starting & Stopping Windows Service?
I have Tomcat running in Windows Server 2008 R2 as Service, I want to setup e-mail alerts whenever the service starts/stopped/re-started.?
is there any Powershell commands? Any Windows event based triggers?
There are many solutions possible (like using Nagios to monitor service status and send an alert).
If you want to use PowerShell...
SOLUTION1: Use Recovery tab to schedule an action ("Run a program"). That action should be a PowerShell script that sends your email...
NOTE: As Jacob kindly said in a comment, action will be triggered only if the service stops by an error.
SOLUTION2: Another possible solution is having a Schedule Task every x time (your choose... 1 min is the minimum) that runs a PowerShell Script. That scripts would:
Check Service Status and compare with previous state (use Get-Service cmdlet)
If the state changes, change previous state and send an email.
You can find here someone that had exactly the same problem and fixed it with Powershell.
Instead of scheduling a recurring task as #cad suggests, you can create a task that will be triggered based on the eventlog :
you could configure it to start on event 7036 of source Service Control Manager from System logfile.
This task can run a powershell script where you can send mail. Short example
Get-EventLog -LogName system -Source "service control manager" -After (get-date).AddMinutes(-5) |?{$_.message -match "tomcat"} | select timegenerated, message
You may want to look into creating a WMI eventing (Win32_Service Class). I haven't used this feature in quite a long time but it look like powershell is making it easier now. This would provide immediate alerting and not require a separate polling process.
https://devblogs.microsoft.com/scripting/an-insiders-guide-to-using-wmi-events-and-powershell/

Resources