Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


New to VPS
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

New to VPS

MavelliMavelli Member

Hello, my first post! :)
Heheh, I see seriesn always put emojis on his posts, this seems fun.
I'm making a multiplayer html5 canvas game. Kinda like an io game, but idk if it's necessary to call it an io game now. Since the hype with io games seems to have toned down.
So, I'm making a client-side html5 canvas, and then a server-side node.js WebSocket server. This was I can host several servers like all those cool io games do. Though, from what I've heard, their servers are all in c++. Anyway, I don't know c++, so I'll just go with node.js first and see how it goes. I don't think a small game like this will be too cpu intensive anyway. Otherwise, I can always just make smaller servers. Then try to learn c++ while my game is up :blush:

I've never heard of a VPS before I started working on my game. VPN, I've heard, but not VPS. After a few days of surfing google and reddit, I found my way here :smile: The discussions here are really interesting, I've looked at the posts as old as those from 2011. It's saddening that many VPS providers disappeared in a year or less. And even worse for those who paid annually.

Anyway, I've digressed. There are so many OS to choose from, and I've like zero experience with anything but windows. Though, I did touch ubuntu a bit. That was for a class in school. But the Virtualbox I installed in ubuntu was crappy slow and ate up several GB of RAM. And I've never liked to try virtualboxing due to this. So all I know is that ubuntu is rather easy to use since it got a desktop. But from the setup page where you order VPS, there are a long list of different OS, like Debian, CentOS, Fedora, CoreOS, Ubuntu,Archlinux, and redhat? and maybe many more. I've googled a bit, and most of they require a minimum from a few GB RAM to 512 MB RAM. Debian 256 MB, and clear linux 128 MB RAM. Yet, I've seen some small NAT VPS with as little as 64 MB RAM, how does that work? :confused:

Can any kind veteran kindly advise me of the advantages with the different OS? My own windows 10 laptop got 8 GB RAM, but it uses up at least 3.8 GB RAM with nothing running. So I presume all OS will have some overhead?

I haven't decided on what kind of VPS to look for yet. I just started with the server-side code. Barely anything yet. The pm2 benchmarked it at 20+ MB. Heh :smirk: Doubt it will stay so low for long. So... My plan is to first finish my server code and have it benchmarked, so I'll have an idea of what kind of VPS to get later on. But it won't hurt for me to start preparing in advance and arm myself with more knowledge :blush:

I'm actually self-taught in JS, so it's probably quite crappy. I've used Webstorm IDE before, it works fine when I launch the node from the IDE, but when I tried to with the cmd, somehow I got an error with the file system module :confused: So I decided to switch to Atom(Also because I don't think my game will count as an educational project once I launch it online? I only got a student license for it). The IDE was for sure much easier to use, it would also help correct problems. So without it, I had to pay more attention to my code on my own. Which is also good. I'm learning more :smile: Though, I had a small problem once I got to writing my server-side code. When I launched the WebSocket server, I couldn't connect it with the client due to RFC2616 with the WebSocket protocol. When I ran the code from Webstorm, there was no such problem.

The solution I found from google, was to add the HTTP headers and proxy to the Nginx, but I don't even have it installed...
it's something like this:
location /wsapp/ {
proxy_pass http://wsbackend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
I kinda did something similar in my node server's http server in js. But it only worked halfway...
But the problem fixed itself after I installed pm2 and ran the node with pm2. Even now, when I just run the node from the cmd, there is no such problem. The only two differences from now, to earlier was that I had apache HTTP server running on the same port as my node. But even when I changed the port for my node server, I still got the WebSocket protocol error. Now I don't know if the problem got fixed due to shutting down the apache HTTP server or not. :confused: (I don't know apache, it was supposed to be for a class which I never really attended due to it being at the same time as another class)

So now I'm also wondering if I need to have a Nginx server running in order to host my WebSocket server? This is kinda confusing... Also, how do you guys host your websites? I could probably do it in apache, just put the folder with index.html and all the resources in the public folder and run the httpd.exe service and voila. But I don't know if that's a good idea though. Whelp, this long post took me about an hour to write x-x

Comments

  • seriesnseriesn Member

    Hola!
    Welcome to the family community. Emojis, while some may find it annoying, it is the closest thing we can get to showing emotions :lol:

    I am not a programmer. So probably someone such as @FAT32 or many many others here would be able to answer the coding related inquires.

    For os, anything with a Graphical UI will be bloated. Linux by default is less resource hungry than straight out of the box windows install.

    Since you are not a "server" person yet, it will be a learning curve and usually free panels like KeyHelp/CentosWebPanel, etc makes your life easy, when you are just starting out. It becomes less frustrating, specially when everything is new :).

    Thanked by 2Mavelli FAT32
  • FAT32FAT32 Administrator, Deal Compiler Extraordinaire
    edited May 2020

    I think there's too many things going on so can't be sure it goes wrong at which point. You only need to use one of the reverse proxy (Apache / Nginx), you don't need to use both of them.

    Node.js is quite low memory usage unless you build some complicated stuff. Running a few hundred active clients on 1GB RAM is sufficient for a basic chat socket.io box. However, if your code is complicated, you might have to take into consideration scaling up by multi-threading (worker threads) in the future because Node.js is single-threaded.

    During early stage when your game is launched, you can look for VPS with high single-threaded performance CPU so you don't have to factor in multi-threading.

    Here's some tips when writing Node.JS apps, especially for your use case:

    1. Use OS independent path / separator: If you read/write from files, don't hard code things like C://Users//mavelli//Desktop//, but instead use utility function from built-in path package (eg. path.join(__dirname, 'file') because different OS have different path separator.

    2. There's a difference with and without trailing slash in the proxy_pass setting: If you do it without the trailing slash, the location path (in your case, /wsapp/ is also passed into your Node.js application, which might cause issues if your Socket.io server is not listening to this path).

    You don't have to think about setting up reverse proxy until your code is ready, you can just use the port exposed by your Node.js server directly while development until you are ready for staging.

    Node.js is not so much of platform dependent when you write it right, I would recommend go with Ubuntu since you have some experience of it, and arguably more updated and beginner friendly. You can try to learn setting up using just pure CLI.

    Don't worry about the optimisation of memory for now. Remember: make it work, make it right, make it fast.

    Thanked by 1Mavelli
  • MavelliMavelli Member

    errh... idek what that means, I just copied it. I've never used Nginx before. But I made a response like this in the nodejs:
    HTTP/1.1 101 Switching Protocols
    Upgrade: websocket
    Connection: Upgrade
    Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
    although I didn't need I later, so I deleted it.
    I guess Ubuntu would do fine. But some providers offer with applications. Like OVH, they have docker, virtualmin, vestacp, all installed on debian 8. well I guess I'll have to see later then. But how do they even run on like 64 MB RAM like those budget NAT VPS?
    Btw I just bought my io domain :blush: I don't even have a website, but can I have my domain name in my signature? :lol: Also I decided to go with apache, the experience will help me if I ever decide to take up that web application class again :tongue:

Sign In or Register to comment.