Mean stack app not working well on AWS EC2 instance - node.js

I have developed a SaaS app using MEAN that is working perfect on my local machines and server now I have deploy my app on AWS EC2 instance.
now I have problem with my server whenever I request with big data query my ec2 instance / server stop I cannot access it from putty or FileZilla.
Should I use other hosting service or there is my app infrastructure problem?
(sorry for bad English)

It seems like your EC2 instance is out of resources, hence not responding to the Putty/FileZilla apps.
You may check the CPU% on the monitoring tab in EC2 console, or via CloudWatch.
Also, You may install and configure CloudWatchAgent on your instance to get improved logging of RAM and also application logs.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html
If the problems is resources (CPU, RAM, Disk), You can change your instance type to a more appropriate one.
BTW, instead of using Putty/FileZilla, you can connect with you instance via the connect tab or session manager (see attached image). Right click on the instance name, and choose "connect".

Related

How does one deploy multiple micro-services in Node on a single AWS EC2 instance?

We are pretty new to AWS and looking to deploy multiple services into one EC2 instance.
Each micro-service is developed in its own repository.
Each service will have its own endpoint URL
Services may talk to each other
Services can be updated/deployed separately
Do we need a beanstalk for each? I hope not.
Thank you in advance
So the way we tackled a similar issue at our workplace was to leverage the multi-container docker platform supported by Elastic Beanstalk in most AWS regions.
The way this works in brief is, we had dedicated repositories for each of our services in ECR (Elastic Container Registry) where the different "versioned" images were deployed using a deploy script.
Once that is configured and set up, all you would need is deploy a Dockerrun.aws.json file which basically highlights all the apps you would want to deploy as part of the docker cluster into 1 EC2 instance (make sure it is big enough to handle multiple applications). This is the file where one would also highlight link between applications (so they can talk to one another), port configurations, logging drivers and groups (yea we used AWS CloudWatch for logging) and many other fields. This JSON is very similar to one's docker-compose.yml which is used to bring up your stack for local development and testing.
I would suggest checking out the sample example configuration that Amazon provides for more information. Also, I found the docker documentation to be pretty helpful in this regard.
Hope this helps!!
It is not clear if you have a particular tool in mind. If you are using any tool for deployment of a single micro-service, multiple should be the same.
How does one deploy multiple micro-services in Node on a single AWS
EC2 instance?
Each micro-service is developed in its own repository.
Services can be updated/deployed separately
This should be the same as deployment of a single micro-service. As long as they have different path and port that they are running on, it should be fine.
Each service will have its own endpoint URL
You can use nginx as a reverse proxy which can redirect your request from port 80 to the required port of your micro service.
Services may talk to each other
This again should not be an issue. You can either call them directly with the port number or via fully qualified name and come back via nginx.

AmazonEC2FullAccess and security

I use Amazon EC2 to host some web sites and databases.
I have a new developer joining me tomorrow.
If I create an IAM User, and attach the "AmazonEC2FullAccess - arn:aws:iam::aws:policy/AmazonEC2FullAccess- Provides full access to Amazon EC2 via the AWS Management Console.) policy to him,
will he be able to access secrets stored inside the linux ec2 instances created in the past. Basically, does this policy somehow allow access to pre-created linux instances.
EDIT: what if he/ she attempts a disk recovery procedure? for example, mount the disk of a vm in a new ec2 instance
When you give AmazonEC2FullAccess access to the user he will be able to see all the EC2 instances in the AWS account. Even if you don't provide him the key to pre-created EC2 instances he will be able to take AMI of the pre created EC2 instance and launch it with a new key and get access to that instance.
He can also do disk recovery procedure as in you mentioned in your use case. So you have some of the below options.
Do not provide AmazonEC2FullAccess ask him what specification he needs for the server and launch the EC2 as per the specification and provide him ssh jailed user access to that EC2 instance.
Set up cloud trail so that you can monitor the resources created by that user for any suspicious activity https://aws.amazon.com/cloudtrail/
Third option is as you mentioned he is developer just provide him deployment and git access to the application running on the EC2 instance.
The IAM role only gives someone access to the AWS EC2 API, where you can do things like create new instances, shutdown existing instances, etc. This does not give someone access to login to any EC2 servers. For that you would need to give someone the SSH key (for Linux) or password (for Windows) that was setup when the server was created.

Data not displaying from website hosted on AWS

I am facing very weird problem.Please help.
I have developed website using MEAN stack and it is hosted on aws ec2 instance.
If I access that website from my laptop, I can see the data(from mongodb installed on server) in my website.But at the same time when I access the website from some other laptop or say mobile phone(using browser), all the tables are coming blank without any data.
I am not getting, why It is working on my laptop as there is no relation between aws instance and my machine.Except that I use their console/dashboard from my machine.
Thanks.
Please check if you set your laptop host file while developing the website to resolve to the AWS EC2 instance IP where your website is hosted.
Or check the EC2 instance security group if you have opened the HTTP port of the instance just to your IP address.
As above 2 are the only causes that might give the issue mentioned by you.

Load-Balancing Windows Azure Instances Locally

When deploying multi-instance WebRole to Windows Azure Emulator, the Emulator is running multiple IIS Express instances of the WebRole, each one on a reserved local IP, like:
127.255.0.1
127.255.0.2
127.255.0.3
The problem is that i want to access the WebRole as if it was really deployed on Azure, i need to check that Session State is persisted between instances.
Since my Session Id is stored on a cookie, each time i'm connecting to a different instance i need to manually 'inject' the cookie to the request to check session data (since the browser considers the IP of the next instance as different domain).
Is there a way i can use a hostname (on a Windows 7 machine) that will point itself randomally to one of those IP?
Well, apparently the emulator does load balance all request between instances:
Clicking 'Debug' on the Cloud Project will open a web page with an IP that is the virtual Load Balancer (usually 127.0.0.1:80 if not taken already).
Yet, there were 2 things that misled me in the first place:
1. The list of multliple IIS Express instances each with it's own binding (image attached).
2. Implicit Affinity:
I made the my web application output the instance-id and kept getting
the same instance-id all the time. the reason for that is (i guess)
the affinity that the emulator enforce (probably using cookie
comparison).
Conclusion:
If you want to manually load balance or to control the affinity yourself, you can leverage IIS Server Farming capabilities (as i did eventually) to emulate load balancing.
(Apache/Nginx as some kind of 'Reverse Proxy' is also a good option, but i preferred to stick with products that are already installed and in-use).

Choosing shared Linux AMI machine image for AWS

I know next to nothing about server management and just got started with Amazon Web Services.
I want to deploy a Linux server which runs Apache, MySQL, phpMyAdmin as well as email capabilities (account mgmt and webmail interface) and backup capabilities. I want to administer the server with a nice web user interface like cPanel, doing things like file management, email account management, access to phpMyAdmin.
Therefore I thought about deploying a shared Linux AMI, instead of building and configuring the server myself. I want to make my life easy, that is, deploying something pre-existing which is easy to manage (web user interface) since I haven't got time to learn all about server management right now.
I found this list of images. Which one of these would fit my requirements?
This is an inappropriate use case for EC2. As Amazons CTO Werner Vogels said a few months ago "an EC2 instance is not a server, it's a building block." EC2 is used to provide computing resources to an application that spans multiple, loosely-coupled services. It's not a drop in replacement for a standard VPS.
That's not to say that a lot of people aren't using EC2 instances as servers. However, these are often the same people who bitterly complain about excessive downtime on AWS without realizing that it's mostly their own fault. An application must be designed to be deployed in a cloud-based environment when it's built on an IaaS platform like AWS. If your application is not aware of autoscaling groups and other high-availability features then traditional dedicated hosting will be cheaper, less complex, and more durable than AWS.
I am aware of AMI's for webmin, but not for cPanel. Here is the link:
https://www.virtualmin.com/documentation/aws/virtualmin_gpl_ami
I would echo the comments made by #jamieb however in that this is really not a good use case for EC2. You are limited to a single elastic IP per instance, so you have no ability to do IP-based virtual hosts as you would with a typical VPS.

Resources