Howdy, Stranger!

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


Websockets & NodeJS - False Positives / Should I be worried?
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.

Websockets & NodeJS - False Positives / Should I be worried?

DillybobDillybob Member
edited June 2015 in General

Before I dive in and launch my web-browser game, I am doing some testing on some live dollar box vps's to get an idea about memory usage and how big of a server I will actually need. Yes I got an idea on my local windows dev PC, but I want to start playing around with iptables and also get more realistic data on live servers instead of localhost.

I did a small flood test with nodejs on Debian 7 to sort of 'emulate' what it would be like on a 256MB ram box from CVPS. Here is 100 158 byte length messages per second:

This has been running for about 5 minutes and yeah, it will eat bandwidth, but the cpu and memory usage seems steady. [Steady as in, 1 person online lol]. The question I have for all of you is: Will network administrator's accidentally see this type of traffic as a flood / dos attack?

Because in actuality, if I have 5 people in a game (my game is instance based), and they are all farming, or killing monsters or moving around the map (updating positioning each click).. 100x requests per second via websockets is not much at all really.. (In total). I cannot imagine if my game has more than 10 or 15 concurrent players online... It will eat up a lot of bandwidth I assume, but I am just a bit scared/nervous what network admins think of this when they see it on their end is all.

Edit: Hell, this isn't even showing the amount of data that the nodejs server will have to send out to each individual player as well...

Comments

  • perennateperennate Member, Host Rep
    edited June 2015

    Run iftop on the server; that will show exactly how much network traffic it's using.

    If the requests are not spawning new TCP connections each time it doesn't seem like it would be a problem. 100*158 bytes (I assume you meant bytes and not bits?) per second is only 15 KB/s.

    Thanked by 1Dillybob
  • DillybobDillybob Member
    edited June 2015

    perennate said: If the requests are not spawning new TCP connections each time it doesn't seem like it would be a problem.

    Oops, yeah bytes.

    I'll take a look into iftop, running it now for a couple minutes brb.

    233 Bytes at 293 requests per second at about 3 minutes:
    iftop data:

    Memory usage around 188mb ~~

    And yeah, I'm going use iptables to throttle that port for new connections. Basically no less than < 1 req per second is what I'm aiming for. Maybe less, depends on user experience. One of the reasons why I need iptables so bad! :)

    I guess a dedicated server with nice bandwidth options is what I basically need, right?

    Edit: By the way, thanks for mentioning iftop, that's nifty.

  • Mark_RMark_R Member

    Worldstream has nice amounts of bandwidth and beefy servers for a good price, you should check them out.

    Thanked by 1Dillybob
  • perennateperennate Member, Host Rep
    edited June 2015

    iftop is reporting 200 kilobits/sec = 25 KB/s. Is that with one player? That means if you have one player online on average on your game, it will take up 64 GB traffic in a month. So a standard 1 TB monthly bandwidth allocation on a virtual private server will get you 15 players online on average, and should be able to easily support 40-50 players at peak usage. As a reference, RamNode's 1024MB SVZ plan comes with 3 TB bandwidth, which gets you 45 players online on average.

    If you're planning on supporting 100-200 players, then sure, you'll want a dedicated server with 1gbps connection and 10TB+ of bandwidth (although at that point bottleneck is probably going to be CPU), otherwise though your usage looks pretty tiny.

    Edit: Oops, I just noticed your CPU/memory usage. That's much bigger problem than your bandwidth. Although still should be able to support 10-50 players on a virtual machine (assuming the memory per player isn't actually ~200 MB, usually the per-player memory decreases with more players?). Cheap dedicated server from soyoustart.com (e.g. the E3-SSD-3) should bump that up to 100-200, they also have ample memory. Of course you need to do more testing with more players to figure out the stats.

    Thanked by 1Dillybob
  • DillybobDillybob Member
    edited June 2015

    perennate said: iftop is reporting 200 kilobits/sec = 25 KB/s. Is that with one player?

    Well, that was at 293 requests per second with 233 bytes which no way on God's green earth is 1 player going to use that much in-game in reality. I was just having fun with setInterval and some Javascript, haha. Hell, in my nodejs I kick players out for making requests faster than 100 ms... So I think your numbers could be way higher I damn hope.

    But then again.. I'm not adding in the mysql usage with nodejs, the temporary inventory object with node that holds all the itemdata in node's buffer.. The users RPG character values..(str, dex, etc). The saving of the players inventory upon leaving a game..
    All the items that a player drops is stored in objects in nodes buffer.. which is sent out as json data for each new player joining a game...HP & MP data per second must be sent to all players in the same game...If a player attacks a mob that data needs to be sent to everyone in the game to update the monsters life for everyone...the list goes on.

    One thing that would really help would be to use binary websockets instead, but too late now :P.

    Now that I think of it... with all this said you're probably not far off... fuck.

    perennate said: If you're planning on supporting 100-200 players, then sure, you'll want a dedicated server with 1gbps connection and 10TB+ of bandwidth (although at that point bottleneck is probably going to be CPU), otherwise though your usage looks pretty tiny.

    Didn't see this for some reason. Thanks.. I'll try to find something similar to these stats for my server.

  • joepie91joepie91 Member, Patron Provider

    I wouldn't worry about it too much :)

    Websockets aren't really anything special - conceptually they're like regular TCP sockets, except the initial handshake is HTTP, and you get message framing for free. That's pretty much it. Mitigation systems are well-adjusted to this kind of traffic.

    Thanked by 1Dillybob
Sign In or Register to comment.