Scaling nodejs, socket.io and mongodb on azure - node.js

We have an application running on a single azure virtual machine (Windows server R12 Data center).
Due to the huge traffic and load, we are planning to scale our system. The application is a game we
have developed on nodeJs, socket.io and mongodb (MongoLab or MLAB ).
Our preliminary plan is as follow :
Scaling the OS : Use azure virtual machine scale set.
Scaling the Database: Given that we are using Mlab (a mongodb database-as-a-service) we believe that scaling is done by them.
Scaling effect on Nodejs and Socket.io : We are not sure...(any hints)
Can anyone with experience on these technologies comment on scaling this stack ?

Azure VM Scale Sets are now generally available. The GA announcement is here: Azure Virtual Machine Scale Sets GA, and the product page is here: Virtual Machine Scale Sets.
When you create an Azure VM scale set, you will create a new resource group with a set number of VMs with the same size, which enables them to scale out and in rapidly and automatically.
You can refer to Azure VM Scale Sets public preview for the overview and general steps of creating an VMSS. And please refer to Automatically scale machines in a Virtual Machine Scale Set for the details of template references.
By the way, you can capture your original VM image, and deploy it to your new VMSS. So that you can save time in deploying your code and runtime environment. Please refer to https://github.com/Azure/azure-quickstart-templates/tree/master/201-vmss-windows-customimage for details.

To scale nodejs with Socket.io you can try horizontal scaling using multicores.
You can either create multiple servers on different ports and use NginX reverse proxy or you can try nodejs cluster module.
Check this link.
Good way to use socket.io with cluster in multi-core server?

Related

Umbraco multisite (around 30 sites) in a single instance along with flexible load balancing in Azure

We have a new requirement, summary follows,
Around 30 sites to be developed.
Should use Umbraco.
All the sites should need have a common Umbraco backend.
Single SQL DB.
Some of the sites will be bilingual.
Load balancing architecture required.
We did the POC for the same with 3 sites in a single instance of umbraco by adding root nodes and assigning proper host name, permissions etc and it worked fine.
But in the real case, will it work smoothly ?
We checked the following article regarding flexible load balancing in Umbraco and planned to move with Azure as it is mentioned as the first choice in the article here.
Is anyone has any similar kind of experience ?
Please share, your help would be greatly appreciated.
AFAIK, Azure Web Apps support Built-in autoscale and load balancing. I assumed that web apps leverage Application Request Routing. ARR Affinity is enabled on your Azure App Service by default. This means that if you are running multiple instance of your App Service, clients will be directed to the same instance for each request. For more details, you could refer to here.
Also, you could leverage Traffic Manager with your azure web app for load balancing, which could distribute the traffic to your web app endpoints in different datacenters (global route traffic).
Here are some tutorials, you could refer to them:
Create a Traffic Manager profile
Scale up your app by changing the pricing tier, then you could get more CPU, memory, disk space, etc. For more details, you could refer to Scale up your pricing tier.
Scale out your app to multiple instances manually or automatically based on your configured performance peaks. For more details, you could refer to Scale instance count manually or automatically.

VMSS scale up with booting executable after launch

I have VM scale set for my Azure ServiceFabric Application deployed in Azure. I need to run RabbitMQ server on each virtual machine in my VM scale set when it starts (especially actual when I am going to scale up my cluster and new VM is going to be created). In other words I want make queue run automatically. Are there any possibilities to do the next steps after VM has been launched:
Check if RabbitMQ is already installed.
Download and install if not from specified URL.
If it has been installed just run it.
I guess this issue can be solved with virtual machine scale set Automation Script, but I am not sure. Any ideas and suggestions?
You could do this using a VM custom script extension. An extension runs on every new VM when a scale set is deployed or when it scales out.
Your extension could do the checks, install and run, and perhaps create a service so RabbitMQ runs if the VM is rebooted etc.
The following articles provide more details on deploying apps with scale sets:
Deploy your application on virtual machine scale sets
How are Applications deployed on VM Scale Sets?

I want to load balance my azure website

I have my website (abc.azurewebsites.net) hosted to Azure Web Apps using Visual Studio.
Now after 1 month I am facing problems with traffic management. My CPU is always 90 - 95% as the number of requests is too high.
Does anyone know how to add Traffic Management in this web app without changing the domain abc.azurewebsites.net? Is it hard coded in my application?
I thought of changing the web app to a Virtual Machine but now as it's already deployed I am scared of domain loss.
When you Scale your Web App you add instances of your current pricing tier and Azure deploys your Web App package to each of them.
There's a Load Balancer over all your instances, so, traffic is automatically load balanced between them. You shouldn't need a Virtual Machine for this and you don't need to configure any extra Traffic Manager.
I can vouch that my company is using Azure Web Apps to manage more than 1000 concurrent users making thousands of requests with just 2-3 instances. It all depends on what your application does and what other resources does it access too, if you implemented or not a caching strategy and what kind of data storage you are using.
High CPU does not always mean high traffic, it's a mix of CPU and Http Queue Length that gives you an idea of how well your instances are handling traffic.
Your solution might implementing a group of things:
Performance tweak your application
Add caching strategies (distributed cache like Azure Redis is a good option)
Increase Web App instances by configuring Auto-Scaling based on HTTP Queue Length / CPU.
You should not have to change your domain to autoscale a Web App, but you may have to change your pricing tier. Scaling to multiple instance is available at Basic pricing tier, and autoscaling starts at Standard tier. Custom domains are allowed at these levels but you don't have to change your domain if you don't want to.
Here is the overview of scaling a web app https://azure.microsoft.com/en-us/documentation/articles/web-sites-scale/
Adding a Virtual Machine (VM) is very costly as compared to adding instance. On top of it, Redundancy (recommended) for the VMs, adding NIC etc will blow up the cost. Maintenance is another challenge. PAAS (webApp etc) is always a better option than IAAS.
Serverless offerings like Azure Functions can also be thought of. They support http trigger and scale up really well.

Bad outgoing connection in Azure VM

I have a virtual machine with CentOs in Azure. Running a web-based application with a connection to the database (via public endpoint).
There is one machine with CentOs, which runs a database (MySQL). Approximately 30% of the connections to the database from the web application failed.
I also use API Facebook, and there are also problems with the connection.
What is the size of your Azure VM? Please note that there are I/O quotas applied to each VM size. Thus XS sized VM has just 20mbps connection, where XL can be up to 1Gbps.
Also please make sure you have Azure VM in an Azure Data Centre location which is closest to your MySQL Db.
I run a code that utilizes FB API on Medium sized VM (Worker Role) and don't have issues with it.

Using Windows Azure SQL Database from Azure VM

Is there any performance penalty to using Windows Azure SQL Database (formerly known as SQL Azure) from within a Windows Azure VM hosted web app? I would like to know if the performance of this is any worse than using Azure SQL database from a website running on Azure reserved instance. The assumption in both scenarios is that Azure SQL Database is deployed in the same region as the app.
There should not be any difference with respect to utilization of SQL Azure
As #Igorek pointed out, there's no difference (assuming same data center) between using a Virtual Machine and a Website for accessing Windows Azure SQL. That said: One thing that may not be so obvious is that, today, Virtual Machines (and Cloud Services) support XL instances (meaning 800Mbps on the NIC) vs Websites, which are currently limited to Large reserved instances (400Mbps). So... if you're moving a considerable amount of data, you'll get better throughput with an XL Virtual Machine vs. a Large Website instance.
I realize this is an edge case, but just thought I'd throw it out there...
There may be some difference in performance which depends on the configuration on the Virtual Machine and the Website Infrastructure where the Website is Hosted.
The connections in-bound and out-bound performances depends on the load balancing which is abstracted in Azure. This relates to the infrastructure which is in place.
For instance if the VM is in Basic Tier More on VM Sizing, and the website is hosted with a higher configuration, you may get some variance in Performance.

Resources