The online racing simulator
LFS Multi server InSim
(24 posts, started )
LFS Multi server InSim
Hi!
I'm going to make a big system for server in my country (Poland). It would be informing players about event's and allow to schedule notes. What language will be best for this if I'm using Debian Lenny on my server. For me, easiest is PHP but I don't know how much CPU and RAM can it take. I think, we'll use this InSim on 100-150 servers.

EDIT:
C++ ? C ? Phyton (please, not)? Delphi (not for sockets and server communication and linux)? Perl (I think it's would be not good too)?
Quote from misiek08 :Hi!
I'm going to make a big system for server in my country (Poland). It would be informing players about event's and allow to schedule notes. What language will be best for this if I'm using Debian Lenny on my server. For me, easiest is PHP but I don't know how much CPU and RAM can it take. I think, we'll use this InSim on 100-150 servers.

EDIT:
C++ ? C ? Phyton (please, not)? Delphi (not for sockets and server communication and linux)? Perl (I think it's would be not good too)?

I'm willing to go as far as say that any programming language you choose these days will not be the choke point, even at 1GHz your computer should be able to handle the amount of data, your connection on the other hand might not be able to handle the amount of data.

With 32 max clients in the server at one time, racing, on track. With an MCI update rate of 50 ms (The minimum allowed - and max packets per second allowed by LFS's InSim System) * 150 servers. Knowing the the max MCI packet size of 228 Bytes (4 + (28 * 8)), getting that 20 times per second gives you 4560 Bytes from one server and multiplying that by 150 servers gives you a max throughput of 668 KB/sec, just in MCI packets. There are of course other variables like network latency that might degrade the performance even more so. I would first make sure that your connection can handle this number of concurrent connections.
No. Without MCI and NLP packets on every server because I don't wonna copy InSim Relay. I only need joining server(NCN) and NPL and maybe LAP and SPX packets in the future. For PB's and WR's.

EDIT:
Ok. 700kB/s ~ 5.6Mb/s. It's not much like for downloading. I have 3Ghz processor and 1,5GB of RAM. Transfer? 5Tb per month. I can get 10Mb connection without transfer limit and it could work but like I wrote above, I don't need MCI and NPL packets on every server. Maybe some servers...
You would need 150 send ports, and 1 listen port. I really have no idea how I would set this up. Do you clone one instance and then propagate it across all of the servers, or do you have one instance and make 150 connections within that instance, then how do you separate the servers from each other.

Is the server going to be saving state information on each server? What's the end game for this program? Are you using it as a central repository for state information on all of your servers?
There is one database. Now it's MySQL and it's working ok. I have 25 connected servers, 4 (or 5) with MCI packets and 2 with NPL packets. 1s interval (1000ms). I'm running on PHP and it's working fast but sometimes lags on 6-7 server (which have MCI/NLP packets ofc). I need something faster because the PHP InSim's are taking too much RAM and too much CPU (CPU isn't problem but RAM consumption is terrible). 1 instance of my PHP InSim System = 1 server so I have 25 "daemons" in PHP running all the time. Maybe after some optimizing, this will take less RAM but I don't have time for rewriting PHP InSim System or making a new one.
PHP will allocate more memory than your script will actually consume, so running multiple instances should be avoided. With a large number of servers, running only one single threaded instance is not really an option though, so PHP is pretty much out of the race. Python or Ruby would be nice high-level alternatives, but neither will come close to C/C++, especially regarding the memory footprint.
So the only way to do it in PHP then would be to have the one listen socket, and the 100-150 send sockets. As it's better to have one instance then 100-150 instances of the same program, and plugins. Each server would have to have it's own clients' and players' array, along with state information, but that should be agnostic to how the plugins see the packet. I'd be quite interested to tackle this problem within PRISM, as I've never really consirered this usage scenario.
Perl and Python are out of race because I don't know them so much. I know perl but only to make a daemon for game/hosting panel. I will try it in C++.
Quote from Dygear :So the only way to do it in PHP then would be to have the one listen socket, and the 100-150 send sockets. As it's better to have one instance then 100-150 instances of the same program, and plugins. Each server would have to have it's own clients' and players' array, along with state information, but that should be agnostic to how the plugins see the packet. I'd be quite interested to tackle this problem within PRISM, as I've never really consirered this usage scenario.

As I mentioned in the PRISM thread, packing / unpacking and instantiating packets is one of the most expensive operations PRISM will perform. Without MCI/NLP or at low frequencies, PRISM might be a viable option. We'll have to find out the hard way once PRISM reaches a working state
Spark Library (http://www.lfsforum.net/showthread.php?t=68564) will be good? It's .net but Airio it's .NET too and it's working by mono very well. I can't check performance now because I don't have time to make new InSim if it will be not good.
Quote from misiek08 :Spark Library (http://www.lfsforum.net/showthread.php?t=68564) will be good? It's .net but Airio it's .NET too and it's working by mono very well. I can't check performance now because I don't have time to make new InSim if it will be not good.

From what I understand, .NET when compiled down in any language should only be about 50% slower then raw C or C++. Don't quote me on it tho.
Nah, no way is it 50%, more like 10-15% slower, and even then it depends hugely upon what you're doing.
But comparing PHP and Spark? Spark will be 100times better? :P

What with connection to MySQL in all languages above?
Quote from DarkTimes :Nah, no way is it 50%, more like 10-15% slower, and even then it depends hugely upon what you're doing.

Really, wow! That's gotten a lot better then when I checked last!

As for PHP Vs .Net, that's slightly an unfair comparison, but I'd like to see the numbers .
There is no built-in support for MySQL in .NET, you need to use a third party library for it, so I'm not sure exactly what the performance would be. I would imagine that with MySQL the main bottleneck would be accessing the database itself, regardless of what language you were using.
Quote from Dygear :As for PHP Vs .Net, that's slightly an unfair comparison, but I'd like to see the numbers .

I had a dig around and found a table showing the performance of PHP 5 vs ASP.NET 2.0

http://www.misfitgeek.com/pages/Perf_Stat_0809.htm

Obviously we're taking compiled-code vs interpreted here, so it is very unfair.
C++ is hard to code. I need very simply language. Sparky lib is very easy like for me. PHP it's kiddy. Thanks for replies. I think, I'm gonna check .NET Sparky library, I'm gonna to check performance.
Wait!
Sorry for double but edits aren't visible as new posts.

What will be better: Python vs Sparky lib.

I saw an Python example and it looks so easy. MySQL in Python isn't hard too.
Spark is much faster than Python.
So mono, Mysql, .NET and it is succes! We will gonna see it. Now i'm going to make 4 server tracker in PHP - easier than everything else.
Quote from DarkTimes :I had a dig around and found a table showing the performance of PHP 5 vs ASP.NET 2.0

http://www.misfitgeek.com/pages/Perf_Stat_0809.htm

Obviously we're taking compiled-code vs interpreted here, so it is very unfair.

The values given seem, disingenuous. Using many, many decimal places for all but ASP.NET gives a false sense that PHP is many many times slower. (And, in most cases, that seems to be the case, when you round the decimal places into the same format.) This leads me to question the impartiality of the benchmarks.


PHP (5.2) PHP (5.3) ASP.NET 2 Diff%
Empty Loop Tests: 20,000,000 Iterations
(For Loop) 1.982 1.449 0.094 (%1542 Slower)
(While Loop) 2.104 1.242 0.095 (%1307 Slower)
(Do While) 1.805 1.169 0.109 (%1073 Slower)

String Assignment Tests: 7,000,000 Iterations
(For Loop) 1.410 1.123 0.040 (%2808 Slower)
(While Loop) 1.450 1.078 0.040 (%2695 Slower)
(Do While) 1.320 1.065 0.032 (%3328 Slower)

Empty Function Calls: 1,500,000 Iterations
(For Loop) 1.199 0.266 0.018 (%1478 Slower)
(While Loop) 1.238 0.263 0.017 (%1547 Slower)
(Do While) 1.186 0.256 0.017 (%1506 Slower)

String & Integer Tests: 600,000 Iterations
1.478 1.594 0.617 (%240 Slower)

Encryption Tests: 2,000 Iterations
1.303 4.965 0.318 (%410 Slower)

Date Function Tests: 3,000 Iterations
1.867 0.297 0.017 (%1747 Slower)

SysVar & Array Tests: 10,000 Iterations
1.127 1.035 0.030 (%3450 Slower)

File System Tests:
File Read Loop (2,000 Iterations)
1.169 1.657 0.306 (%382 Slower)
Metadata Read Loop (9,000 Iterations)
1.284 1.400 0.948 (%135 Slower)
File Copy Loop (10,000 Iterations)
1.960 2.495 6.548 (%334 Faster)

Objects Tests: 350,000 Iterations
1.258 0.861 0.031 (%2777 Slower)

MySQL DataBase Tests: 1,000 Iterations
1.243 5.431 NoData (NA)

Postgres DataBase Tests: 1,000 Iterations
0.289 0.249 NoData (NA)

MS SQL Server DataBase Tests: 1,000 Iterations
0.521 NoData 0.295 (%177 Slower)

Seems to me, that in most cases, using the best version of PHP, php is normally about 17 times slower then ASP.NET, but when it comes to Accessing a SQL server, it's only about twice as slow. PHP does win in one case, that was file copy, where it was 3.35 times faster then ASP.NET. So, if your doing file copy operations, do it in PHP, for everything else, there's ASP.NET.
Sorry but one more question. Will work Spark library in the command line. I have to read screen content via Perl daemon or SSH2 in PHP or output everything from InSim to debug file and read this file by above written technologies.
You cannot use Spark from the command line, it's just a DLL. You will need to write your own .NET console application to use it from the command line.
I know but the 2nd library (External?) is used in Form applications so I thought that .NET External library can't be used in console and Spark looks like it be working on the command line.

LFS Multi server InSim
(24 posts, started )
FGED GREDG RDFGDR GSFDG