Can I use HTTP for a realtime multi-player server?
#1 Members - Reputation: 407
Posted 01 August 2012 - 11:27 AM
The entire game-state is managed on a single machine ( No state negotiation ).
As such, a small lag is not a big problem. Where small ~= 1 sec .
Even though, the state is hefty, and ever-changing.
Would it be wise to build my multi-player server over HTTP?
For HTTP:
* Game runs on cell phones & HTTP is firewall friendly
* Easier to find hosting for HTTP ( PHP/Google )
* Game runs on cell phones no need to worry about connections being dropped
* Can consolidate several game packets into a single HTTP call
For TCP/IP:
* I am pretty proficient with TCP/IP (done many low-level communications).
* Making new connections over and over is really expensive on performance.
* Need to worry about reconnections after connection drops (cell-phone game)
* Cheap HTTP hosting might not be performant enough for my needs.
* If I ever want to make a peer 2 peer connection, I would need an HTTP server on one of the devices.
So what do you think is HTTP an option for a real time game?
Has any of you ever tried?
#2 Members - Reputation: 852
Posted 01 August 2012 - 11:56 AM
http://browserquest.mozilla.org/
http://nodegames.blogspot.com/
The server is running node.js from what i understand.
-ddn
#3 Members - Reputation: 407
Posted 01 August 2012 - 03:34 PM
I think u can use something like websockets using javascript through a webpage does that quality as using HTTP? See the most famous example of
http://browserquest.mozilla.org/
http://nodegames.blogspot.com/
The server is running node.js from what i understand.
-ddn
Thanks, I am not writing a web-app. I am writing a java app. That app can either open a TCP socket and communicate over that, or make HTTP requests. I am wondering if HTTP requests are any good for my needs.
Regardless of this, I have used web-sockets on another project of mine, and they are quite neat and straight forward. They are not HTTP though.
#4 Moderators - Reputation: 7793
Posted 01 August 2012 - 05:16 PM
[Work - ArenaNet] [Epoch Language] [Scribblings] [Journal - peek into my shattered mind]
#5 Members - Reputation: 407
Posted 01 August 2012 - 11:55 PM
But the question is a More general one. Is http even feesable or would a overhead kill me?
#6 Members - Reputation: 380
Posted 02 August 2012 - 01:37 AM
The server is able to use several optimizations and to take care on the capabilities of the client to send content in a way that leads to an always right presentation of the content.
So. If you use a kind of web-browser as the front-end it is OK to use HTTP.
If you use a special client as front-end any other protocol on top of TCP/IP will be a good choice.
HTTP and TCP/IP are different layers and so they are hardly comparable.
#7 Moderators - Reputation: 3296
Posted 02 August 2012 - 10:01 AM
HTTP is very inefficient, as it has the sender send lots of header data for each request, and has the server respond with lots of header data in each response, too. Additionally, it forces you to re-establish credentials in each request, re-establish the underlying HTTP connection occasionally, etc.
#8 Members - Reputation: 407
Posted 03 August 2012 - 07:29 AM
Http hosting (port 80 tcp/ip with headers) is more common and cheaper. I can use some cheap php/java servelet host. Maybe try out google app engine.For tcp/ip i need a full virtual machine, which seems much more expensive.
I wanted to know if my assumptions have any hold in reality. I am trying to aproach this on a cost for value approach.
#9 Members - Reputation: 350
Posted 03 August 2012 - 09:40 AM
9 times out of 10, if you're considering HTTP for a non browser game, you need to look in to other options.
#10 Moderators - Reputation: 3296
Posted 04 August 2012 - 12:47 PM
However, planning the networking for a game around cheap HTTP-based hosting is not how to go about a successful project.
If you have any kind of success with your game, you will presumably be able to make enough money to pay for real dedicated hosting as needed.
#11 Members - Reputation: 37
Posted 04 August 2012 - 08:11 PM
what if your game, before it strats, makes a reqest for xml scene and elements data,so that it can bring player to game? Nice idea. Imagine you could wake up one morning, and to all the players bring new stuff, scene,. just by updating document and files in text of the document.
#12 Members - Reputation: 37
Posted 04 August 2012 - 08:20 PM
And I would stress that, you should provide your own aplication that serves your clients, but for that you will need a box, and that is not 2GB dedicated on a host machine, housing a box on a up link costs 80 euro. But if your aplication visits some http domains, it might be very benefitial for your aplication, though volatile data will have to be exchanged defintily not by http protocol, but by raw abstraction between udp link you established between your aplications and server. But games might find big use of http, but in other manners than constant interaction between players.planning the networking for a game around cheap HTTP-based hosting is not how to go about
#13 Members - Reputation: 380
Posted 05 August 2012 - 03:04 AM
I wrote a web-server of my own and it always let the connections stay open for some time (normaly 60 seconds). A web-browser creates numerous connection in parallel if there are references to content is on the page. The number of connections vary. Some use google as a proxy service where you can get a dozen connections in parallel for the requested page content but every request comes from another IP. The only way to "see" that all requests are from the same client would be cookie with some session id.HTTP protocol can work for not often updated system. Simply in http, you find out distant data only by making request and getting answer. Http request and http answer are rather many bytes (file, text), and after request is made, it recieves the answer , and connection is close . unless you specify "Connection:Keep-Alive" header, so that client may use the connection for other requests it fires (src's of img , css. js. in link tag and all data it knows url for), nearly no server supports it and your browser allways recieve "Connection:Close" header in answer, so these are allways separate reqests.
It would be possible to create a stream connection to a browser. You can send a reply without giving a size information and afterwards send chunks of data on this stream.
This way you can stream a video to a client.
#14 Members - Reputation: 37
Posted 05 August 2012 - 10:01 AM
Yes, you could fake constant data update by streaming a dynamic file, but only in server-to-client direction, as it would be very monstrous to collect data from clients that server needs through http hammering requests .You can send a reply without giving a size information and afterwards send chunks of data on this stream.
This way you can stream a video to a client.
#15 Members - Reputation: 407
Posted 05 August 2012 - 02:22 PM
Yes, you could fake constant data update by streaming a dynamic file, but only in server-to-client direction, as it would be very monstrous to collect data from clients that server needs through http hammering requests .
You can send a reply without giving a size information and afterwards send chunks of data on this stream.
This way you can stream a video to a client.
Not a problem for me, as I am buffering input. Whenever a client lags, it buffers pending requests. Then an http request with many messages is sent. I can also dynamically control the rate of requests, thereby forcing a buffer to minimize requests even if the client does not lag.






