Skip to main content
GameDev.net gamedev.net
🔒 Locked

Online Design Help

Started by SoftwareDeveloper Nov 16, 2009 at 5:36 PM 8 replies 1.6k views
Original Post
SoftwareDeveloper
SoftwareDeveloper
Hi.. long time reader.. first time poster.. :) While I am not a game developer, I find that this forum is amazing for good network coding practices and help. So, I am here to ask for your help. My design is very similar to an online game host system. I am trying to write a cloud solution for an application model that I have. The current application model is a simple client server. Photobucket Clients connect to the server and the server keeps the connected clients updated. This would be considered a session. The conceptual cloud model would look like this: Photobucket There would simply be multiple sessions running online. The cloud solution would simply look like one more connection to the server. The server would update its clients (the cloud being one of them) and the cloud would take that update and send it to all of the connected clients that are in that session (minus the sender of course). the physical model would look like this: Photobucket The basic idea is that each person connecting would connect to the gateway. They will be interrogated as to what session they want. They can request a list of all active sessions. Display that to the user and determine which session they want. When one is selected they request a session info from the gateway. (basically.. what server is hosting this session). As soon as they get the ip and port. they disconnect and connect to that server (SessionMgr). The sessionMgr has one listening socket.. SessionMgr interrogates the connection as well and ask what session they want. SessionMgr places that connected socket into the object hosting that session. One object (class) per session. The object will be overlapped i/o and will use 1 thread. AKA 1 thread per session. my question are: 1. Is this similar to how an online game solution would/could be designed? 2. What are the major drawbacks with TCP/IP with the internet (versus http/soap/etc) 2a. Do games that play online use tcp/ip or something else? 3. I was thinking of having both the gateway and the sessionmgr be a service. I was going to write it in ATL so I could use COM as well (attach my own debuggers and stuff using COM) 4. When needing a connection to a database, what is best? Is an active connection from each service (Gateway and Sessionmgr) good or some other solution like web services be better. Thanks in advance for all of your input!
hplus0603
hplus0603
5. What parts of the Forum FAQ do you feel do not answer your questions?
enum Bool { True, False, FileNotFound };
SoftwareDeveloper
SoftwareDeveloper
db connections

is it considered bad design to have an entire session on one computer. If someone wanted to crash that session, they would simply slam that system. if it was a distributed system (connections on any system can talk to any connection on any other system) style, it makes it alot harder to crash...
SoftwareDeveloper
SoftwareDeveloper
to clarify..

what is the best way to connect to the db? Has anyone used web services for this? or do you just have a straight db connection from the system and make your queries/stored procs calls...

also.. how do you guard against attacks when the each game is on a system. if someone attacks that one system (if they know which game they want to take down) it will take down the entire game.
Antheus
Antheus
Quote:
Original post by SoftwareDeveloper
what is the best way to connect to the db? Has anyone used web services for this? or do you just have a straight db connection from the system and make your queries/stored procs calls...

Anything that is not under your authoritative control should not have direct access to database.

So there needs to be something sitting in between. What exactly depends on requirements.

Quote:
how do you guard against attacks when the each game is on a system. if someone attacks that one system (if they know which game they want to take down) it will take down the entire game.


There are several attack vectors. Each can be guarded against to a sensible degree. But this is a too broad a question.

Just about the only generic advice that applies is instrumentation and notification. Have some network monitoring system in place, log all actions, and such, so that when something goes wrong you have somewhere to start.

Many of the problems here are administrative. For example, have the phone number of on-call person that hosts your servers in case of a large-scale DoS attack.

Because calling people from your company on Saturday to find out which company even hosts your servers 10 hours into DoS is not exactly a valid contingency plan. Oh the fun of saving money no matter the cost....
hplus0603
hplus0603
Quote:
what is the best way to connect to the db


At some point, you have an application server that talks to the DB using its native networking interface (or through a client library like ADO or libmysql or whatever). The DB machine itself should not be visible to any machine that is not under your absolute control, if you care about the integrity of the DB.

It is possible to build scalable systems where the user talks to a front-tier application server, which talks to a back-end application server (typically brokered by a message bus), which talks to databases. However, whether that is something you need, or just something that is massive overkill for your intended application, is hard to tell without knowing the specific economic projections of the application.
enum Bool { True, False, FileNotFound };
SoftwareDeveloper
SoftwareDeveloper
actually.. mentioning ADO is perfect lol.. I see that it is no longer "maintained"? Is that correct? Last version was 2.7/2.8.. Is that still "safe" to use?
hplus0603
hplus0603
Isn't "mysql" the current standard database protocol? :-)

At my previous place of work, we wrote an asynchronous wire protocol handler for MySQL in C++. At my current place of work, we use PHP and Python built-in APIs for MySQL, with caching in memcached.

Regarding ADO -- if it works, you can still use it, but if you write new code right now, you'd probably want to use something more modern. Generally, though, you'll want to write a database layer in your application that allows you to re-vector to whatever database API you want, and use the "native" database API instead of a wrapper like ODBC. In general, that turns out to perform better, and actually make for a reasonably easy transition if you ever switch databases.
enum Bool { True, False, FileNotFound };
SoftwareDeveloper
SoftwareDeveloper
while I am planning on 3-tier, I always found it hard to get high cohesion with the DAL and Buisiness layer.

my DALs calls typically returned a recordset or some proprietary structure (depending on the database) and the Business layer returned the data from that structure or in some other generic format (ie xml) but that was only when needed.. I guess I could convert the data from the DAL to XML format but that seems like a lot of parsing. especially in the circumstances where the returned value from the busines layer doesn't need to be xml..

any suggestions on a better separation from the DAL and business??

though, I do suppose that if the DAL was changed, the data inside the bus. layer would also have to change as well.. storedprocs might not be allowed, queries might have to be redesigned, etc.. is there really a way to change the DAL without affecting the business layer or would my Businesslayer class still be considered in the DAL?

ex _pseudo_ code
class DAL{ bool open(tchar* constr, ...); bool close(); rec* ExecuteStoredProc(tchar* name); protected:  connection con;};class Businesslayer{  Businesslayer(connection* pconn);  xml ConvertRecToXML(const rec*);  inline xml getallusers()  {    rec* prec = pconn->executestoredproc("dbo.spGetAllUsers");    if (prec)    {      return ConvertRecToXML(prec);    }    return NULL;  }  inline int getuserscount()  {    rec* prec = pconn->executestoredproc("dbo.spGetUserCount");    if (prec)    {      //whatever lol      return prec->rows->row[0]->getvalue();    }    return NULL;  }}
hplus0603
hplus0603
A DAL necessarily has to know about the needs of the business, or it won't be efficient. Business logic necessarily needs to know what the data is, or it can't do its job. Typically, layering will look something like:

Clients <-> Business Logic <-> Data Access <-> Data Storage

If you change data storage, then data access needs to change. The role of Data Access is to prepare the data in the format that Business Logic wants it. Clearly, the design of the data interface to the Business Logic layer needs to take performance and scalability into account, but it probably shouldn't be extremely tightly tied to the current Data Storage, or the Data Access layer isn't needed.

enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.