Which azure option is good for my TCP game server using node.js? - node.js

I am new to Microsoft windows azure cloud and want to run my game server using node.js in azure cloud. I read the windows azure Node.js Developer Center site and it seems my server can run in azure cloud multiple ways.
Which azure option is good for my TCP game server using node.js?

Three options:
Web Site
Cloud Service
Virtual Machine
Web Sites are essentially shared web hosting, which only supports HTTP, so not an option for you.
Cloud Services are probably what you want. This is the core PaaS offering on Windows Azure. It will let you run pretty much whatever you want, as long as it runs on Windows. It supports TCP endpoints. There's are pretty nice tools for Node.js. There are two flavors of running Node in a Cloud Service: a web role or a worker role. Web roles use IIS and run Node.js behind it. That won't work for your raw TCP connections, so you'll want to use a worker role. A worker role will simply launch your Node app and leave it running forever.
Virtual Machines would work fine too, but they don't provide much value compared to Cloud Services. In a cloud service, you can spin up new VMs on demand, a load balancer sits in front of your app distributing traffic, your app will get restarted if it ever crashes, you can have your VM automatically patched without downtime, etc. Unless you can't run in a cloud service for some reason, you rarely want to use a raw VM.
tl;dr You want a worker role in a cloud service. :-)

Windows Azure does have a toolkit for Social Games on Github, this might help you in you in your endeavours, not sure it supports Node.js mind you, there should be some takeaways to help you.
https://github.com/WindowsAzure-Toolkits/wa-toolkit-games
This blog post gives a good breakdown on where to run what and use cases for each.
http://blogs.msdn.com/b/silverlining/archive/2012/06/27/windows-azure-websites-web-roles-and-vms-when-to-use-which.aspx
It really depends on your application, what backend does it have, number of users, performance, latency etc...

A word of warning though, running Node.js on Windows is mostly fine but there are several libraries that will not work. Don't know if it's a hard requirement that you use Azure but there are other Node hosting solutions out there.
Nodejitsu
Nodester
Those are only two, there are more out there.
Disclaimer: I'm building a Node.js hosting solution, modulus.io.

Related

how to run a node server in an azure virtual machine permanently?

I build a web based mobile app (using react), which I'm hosting as an Azure Web app. This website is connected to a node server, which I'm hosting using a azure virtual machine (I don't know if this is the best approach, maybe I should host this as a webapp instead of VM ?).
I'm still new to this strategie of developing a web based mobile app and connecting it to a hosted backend in the cloud so I apologize if this is a trivial question.
I'm using websockets to connect my frontend to the node server and then I consume messages. I don't have a database it is a simple application.
The steps I'm doing to run the app are:
I connect to the Azure VM from my laptop with ssh
run my server using node server.js
When the server is runing, I can refresh my website and everything works fine
Now, the problem is that I want the node server to run all the time. However, I noticed that the server stops running when I deconnect (ssh) my laptop from the virtual machine. So I find myself doing these steps (connecting to the VM with ssh and running the server manually) each time I want to use the app.
Is there a way to do this so that the node server runs all the time without stoping? Also since I'm new to this, is this the right way to deploy frontend and backend? I assume I can't deploy both frontend and backend in the same Azure webapp or am I wrong?
(Since part of your question is around "Is there a better way?", I would answer that instead of fixing the issue in your current VM hosting :)).
To take full advantage of cloud for your applications, PaaS is always preferred over IaaS. In this case, unless you have any specific reason, you should deploy your backend Node app in another App Service (aka Web App). Or you can consider Azure Function also if your node app has a small set of APIs, but it will require code update. Both support multiple platforms including node.js. Since you mentioned you are leveraging Web App for your react mobile app, so I hope you are already bit familiar with it. Also since Azure Function would require code change, so Web App is preferred this case.
Note: I omitted other solutions like AKS, Service Fabric etc. for now, since currently we are talking about the problem of deploying only a single app, for which those will be overkill at this moment.
Also, to your point
I assume I can't deploy both frontend and backend in the same Azure webapp or am I wrong?
Yes technically you can, depending on your scenario by "bundling" into a single app if both are in same platform (like Node in this case). Though whether one should do that would be an opinionated answer. But even if you keep those separate, you can still leverage single App Service Plan for cost saving. So keeping separate like you have now is what I would suggest to maintain "separation of concern".

Do we need iis server installed in azure cloud to host a web app in azure

If I need to host a web app in azure cloud, do I need to install windows server and iis in a VM or is there any other option like the web service running separately?
I have read azure app service while googled, if it's been used, Will it serve all the purpose of an iis?
In most scenarios you do not have to host a VM with IIS to host a web app in Azure. You can, but unless you want or need to manually manage a VM because you for instance need to install software on the server, there are simpler hosting alternatives.
Have a look at Azure App Service
Azure App Service is a service for hosting web applications, REST APIs, and mobile back ends. You can develop in your favorite language, be it .NET, .NET Core, Java, Ruby, Node.js, PHP, or Python. Applications run and scale with ease on both Windows and Linux-based environments.
EDIT:
As far as monitoring goes: there is a lot available to monitor the performance of an App Service. For instance:
Application Insights
Monitor apps in Azure App Service
EDIT2:
Will it serve all the purpose of an iis?
Are you looking for a specific purpose? Azure App Service brings you a LOT of possibilities. Sure, it's PaaS and therefore you're bound by the options available for the specific service. But you're also getting a lot of extra's IIS doesn't provide (out of the box). And when you're running a website that doesn't require you to install any COM stuff or something specific like that, there's nothing App Service doesn't provide.

Allow localhost endpoint in different Azure hosting options

I use a small webserver for inter-process-communication between .NET and and an executable process on the same machine, i.e. a POST request to http://localhost:3000/
This works fine on my local machine when I allow the process with Windows Firewall.
Having tried the same on Azure Websites, I get an error (kind of expected).
Now my question is, which of the other services allows me to open a port and listen locally? All of them? (VM, Workers, Web Roles)
Thanks
When you want to open a PORT (socket) you can use either of VM, Web Role or Worker Role. You just have to be aware of the specifics of each. Just quick tip for differences:
VM is a IaaS Service (Infrastructure-as-a-Service) - this is where you get a VM with OS and you take care of the OS from then on - updates, patches, everything
Web/Worker Roles are PaaS Service (Platform-as-a-Service) - here you get (a fully customizable) environment under Windows OS to run your code. However about OS and Framework patches and updates someone else is taking care of.
One very good article explaining IaaS, PaaS, SaaS is Pizza-as-a-Service. Which I recommend reading.
Then for your concrete scenario, I would advice you to go for a WebRole. You can combine WebRole with worker processes. Here is a quick tip on how to do this.
But, whenever you go for the cloud, be sure to check out the Azure migration cheat-sheet.

Azure cloud service and web sites communication lock down

I have a azure cloud service (a server) where i host a Redis database. I also have a web site hosted in azure web sites. I want the web site to be able to talk to the Redis DB on port 6379. I know I can configure a public endpoint for that port on my server but that would open it for whole Internet. I want it opened only for azure web sites (or even better, only for my web site). How can i do this?
Windows Azure Web Sites is in an isolation bubble separate from your Cloud Services and there's no way to bridge that gap. Ideally you'd do this by connecting the web site machine to other Azure services via a Virtual Network, but this FAQ confirms you can't do that right now:
Can I use Windows Azure websites with Virtual Network?
No. We do not support websites with virtual networks.
Opening Redis up over the internet shouldn't even be considered as it doesn't have the kind of security you'd want out of the box to be opening up its port publicly as it is meant to be co-located with your application, so you really wouldn't want to do that. Never mind the added network overhead which will eat into the performance you expect to get by leveraging something like Redis anyway.
I believe your best bet given your current configuration is to add a Web Role that's part of the same Azure Cloud Service and run your web based application out of that so that it can communicate with worker role. It only requires a little bit of configuration to get this going (i.e. adding an InternalEndpoint to the Redis Worker Role). While I realize Web Roles don't offer as frictionless a development model as Web Sites, you have to choose the right tool for the job.
Another option, if you want to setup your Redis on a VM instead of tying it to the Cloud Service directly, is that you can setup a Virtual Network, put the Redis VM on the virtual network and then configure the Cloud Service so that it's part of the same affinity group and add the NetworkConfiguration/VirtualNetworkSite configuration section to the Cloud Service's .cscfg.
Which approach makes more sense all depends on how you leverage your Redis instance, but the main benefit of the latter approach is that the Redis instance is not recreated each time you deploy your Cloud Service and, so, any data that's in it will stay available between deployments. Another benefit is if you want to build and leverage a Redis cluster across multiple Cloud Services this enables you to do that.

What is the difference between Azure Web Site and Azure Cloud service

We are looking to host a website (some css,js, one html file but not aspx, one generic handler).
We deployed in as:
1) Azure Web Site
2) Azure Cloud Service
Both solutions work. There is a question though: which way of hosting it is better and why? Second thing: as there might be a lot of traffic - which solution would be cheaper?
Thanks in advance,
Krzysztofuncjusz
You may want to review this article that explains the primary differences. Web Sites are best for running web applications that are relatively isolated (that do not require elevated security, remote desktop, network isolation...). Cloud services are more advanced because they give you more control over web sites while still remaining flexible. And VMs are for full control over applications that need to be installed and configured (like running SQL Server for example).
I think that main difference in abilities to modify VM and possibility to configure scalability. Web sites is something like classic hosting, without ability to login by rdp. Cloud Services allows you to configure VM and if necessary setup scalability and availability.

Resources