Need some help with where to start, please
by Vince Gee · in Torque Game Engine · 07/14/2005 (6:19 pm) · 9 replies
I am trying to improve the performance of the game server, now this server uses an odbc connection to record persistent data to a sql server. The problem I have is that the SQL connections are tcp and thus synchronous.
So when a player logs in, they hang the server for a second as the sql server retrieves their data.
What I'm thinking is that instead of having the server make the odbc connection, instead it sends an udp message to a queue and the queue does the lookup and sends a message back to the server with the data. This way the players already in the game do not get the split second lag of it waiting for the database to respond.
Now, unfortunately I do not know enough about socket programming to do more than follow directions. I found a resource on the internet which helped me set up sockets, but when I try to import them into the head they throw errors saying that a couple virtual destructors are already defined (WinThread.h) and that some other stuff is already defined "WinMemory.h".
I was wondering, if anyone has gotten something like this to work, where a udp packet able to be directed at an ip and forgotten about? I know torque uses udp in it's network base, but I lack the talent to expand it. I have the udp server functioning, I just need a way to send udp messages to it on a port like socket.sendmessage(IP,port,"Message string");
If anyone could give me some pointers or tell me which files I need to extend (Or maybe point me at a resource) I would be greatly appreciative.
Vince Gee
A humble servant of Garage Games :)
So when a player logs in, they hang the server for a second as the sql server retrieves their data.
What I'm thinking is that instead of having the server make the odbc connection, instead it sends an udp message to a queue and the queue does the lookup and sends a message back to the server with the data. This way the players already in the game do not get the split second lag of it waiting for the database to respond.
Now, unfortunately I do not know enough about socket programming to do more than follow directions. I found a resource on the internet which helped me set up sockets, but when I try to import them into the head they throw errors saying that a couple virtual destructors are already defined (WinThread.h) and that some other stuff is already defined "WinMemory.h".
I was wondering, if anyone has gotten something like this to work, where a udp packet able to be directed at an ip and forgotten about? I know torque uses udp in it's network base, but I lack the talent to expand it. I have the udp server functioning, I just need a way to send udp messages to it on a port like socket.sendmessage(IP,port,"Message string");
If anyone could give me some pointers or tell me which files I need to extend (Or maybe point me at a resource) I would be greatly appreciative.
Vince Gee
A humble servant of Garage Games :)
About the author
www.winterleafentertainment.com
#3
07/15/2005 (4:53 am)
Unless you're planning to have like a few hundred users logging in at exactly the same second, this won't be much of a problem.. or would it?
#4
Vince
07/15/2005 (4:57 am)
Well it was on my test server. It's not really an issue if all your doing is checking a password, but if your loading stat's, inventory, etc. and your database is complex (Even w/ indexes for performance) your going to get a 1-2 second lag as the server does the query. Theirs no way around it since the connection negotiation between the tge engine and the sql server will take a second or so.Vince
#5
07/15/2005 (5:03 am)
I thought the TGE server would continue to operate as normal when the query was processed..
#6
Vince
07/15/2005 (5:16 am)
Well, I guess it matters how your doing it. I'm using the odbc resource mod and it doesn't create a thread for the sql call thus it hangs the server. I guess one option would be to put the odbc code into a thread and have it do a call back when it's done.Vince
#7
07/15/2005 (9:01 am)
Any info yet Ben?
#8
Vince
Sockets.lib(SocketHandler.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj
Sockets.lib(Thread.obj) : error LNK2005: "public: virtual __thiscall Thread::~Thread(void)" (??1Thread@@UAE@XZ) already defined in winThread.obj
Sockets.lib(TcpSocket.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj
../example/TSE.exe : fatal error LNK1169: one or more multiply defined symbols found
07/15/2005 (9:11 am)
The following errors are what I get when I try to include the library.. anyone have any ideas on what I'm to look for to fix it?Vince
Sockets.lib(SocketHandler.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj
Sockets.lib(Thread.obj) : error LNK2005: "public: virtual __thiscall Thread::~Thread(void)" (??1Thread@@UAE@XZ) already defined in winThread.obj
Sockets.lib(TcpSocket.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj
../example/TSE.exe : fatal error LNK1169: one or more multiply defined symbols found
#9
There are two options for you. First, you could set up a secondary "database server", connect to it from your servers, and have it do queries and post the results back to you. Second, you could keep a pool of threads around and a list of the queries you want to do. Each thread grabs a query, does it, and shoves the results somewhere so you can continue processing.
The latter approach is probably going to be better for you. TNL has an excellent implementation of just such a system.
Either way it is going to take some high quality coding to get things off the ground; you may want to try to work with a more experienced programmer (especially if you're doing threads, as they can blow up nastily in your face).
You can also try some hacky stuff like spawning a new thread for each DB query, but that can get ugly quickly, too.
07/18/2005 (12:57 pm)
You probably don't need to use random example networking code. Torque has its own solutions to those problems already.There are two options for you. First, you could set up a secondary "database server", connect to it from your servers, and have it do queries and post the results back to you. Second, you could keep a pool of threads around and a list of the queries you want to do. Each thread grabs a query, does it, and shoves the results somewhere so you can continue processing.
The latter approach is probably going to be better for you. TNL has an excellent implementation of just such a system.
Either way it is going to take some high quality coding to get things off the ground; you may want to try to work with a more experienced programmer (especially if you're doing threads, as they can blow up nastily in your face).
You can also try some hacky stuff like spawning a new thread for each DB query, but that can get ugly quickly, too.
Associate Kyle Carter