-3

I have to start a program on several computers at the same time (within ms). The program read out of and write into a mysql database. To ensure the simultaneous start, I thought about the sql dependency but does it also work for mysql? Are there any other ways to guarantee the synchronous start?

It´s a project inside a laboratory. So it´s just a small network.

Greetz

tk5
  • 19
  • 3
  • you can't guarantee a synchronous start (within ms) on several computers to much variables like used hardware, current cpu load en current disk i/o load. – Raymond Nijland Nov 23 '17 at 14:45
  • how are you starting the programs?? – Steve Nov 23 '17 at 14:45
  • And just think if one of the computer get hit by an elephant, there will be no starting on that anymore – Sir Rufo Nov 23 '17 at 14:46
  • *Why* do you want multiple computers to start at the same time? If you want to stress test something, that's not how it's done. – Panagiotis Kanavos Nov 23 '17 at 14:53
  • The loading time could differ couple seconds between SSD and None SSD, differ due to CPU speed, RAM speed, computer usage, or even in rare cases when Windows update kicks in! – Steve Nov 23 '17 at 14:55
  • You could control multiple agents from one machine and eg send a command to each one in parallel to start. Or broadcast/send multiple UDP packages to all so that they will get the notification eventually. You *can't* guarantee that they will all receive the message withing milliseconds - the OS may be running another application. You *can* specify the current time and a short time in future in the messages though, so that all agents can calculate a clock skew and start at *roughly* the same time. – Panagiotis Kanavos Nov 23 '17 at 14:58
  • I want to take a look at the access time to the mysql database if the isolation levels changed. – tk5 Nov 23 '17 at 14:58
  • Or you can use any testing framework, eg Visual Studio's own framework and agents to do that for you – Panagiotis Kanavos Nov 23 '17 at 14:59
  • @tk5 and as I said, that's not how it's done. That's not how *database benchmarks* work. And access time has NOTHING to do with the isolation level anyway. If you have a performance problem, check your queries, your indexes and CLOSE your connections immediatelly after use. Don't try to cover it up by allowing dirty data. You won't fix anything if you keep connections open for minutes or hours but allow them to read each other's dirty data – Panagiotis Kanavos Nov 23 '17 at 14:59
  • @Panagiotis Kanavos There is no performance problem. It´s just a little update statement. I just need to know how long does it take to update a database if there are several computers in a small network which also want to update the db at the same time. And how big is the affect of the different isolation levels. – tk5 Nov 23 '17 at 15:21

1 Answers1

-1

Synchronyze Operating System clocks with and NTP and schedule the start (once loaded) to ensure real-time synchrony.

Run your program with a clocktime to start, and put some trigger to do it.

I'm working for years in distributed systems and is the most common solution.

Accuracy on todays clocks starts on nanosecs (10^-6 secs) and there's high accuracy clocks (10^-7 till 10^-8 secs)

You can read a discussion about clocks here and Time synchronization vs alternatives here

Alfonso Tienda
  • 3,442
  • 1
  • 19
  • 34
  • Nope, even loading the executable into ram may differ, so the real start time is different – Sir Rufo Nov 23 '17 at 14:49
  • and you forgot to mention OS clock is never accurate. unless you got an atomic clock attached – Steve Nov 23 '17 at 14:51
  • This is also assuming the scheduler has millisecond accuracy, which I doubt it has. – DavidG Nov 23 '17 at 14:52
  • @DavidG Of course it has, The clocks are much more perfect than a millisecond . Sir Rufo, you syncronize the start, not the load, before the program begins. I've done this dozens of times running thousands of equipments perfectly synchronized. – Alfonso Tienda Nov 23 '17 at 15:24
  • The clocks are, but is the scheduler? Can you guarantee it will kick off at the exact millisecond you require? – DavidG Nov 23 '17 at 15:38
  • Pass a schedule time to the program. The first lines will wait to the time. You can put your clock in nanoseconds, for more accuracy. I have never implemented in C, but there are an example here: https://stackoverflow.com/questions/14650885/how-to-create-timer-events-using-c-11 . My team synchronized 100+ cameras to take 40 pics a second, synichronized. Of course there's some difference, but all the cameras took a pic in almost the same milisecond. It depends in many factors, as networks, but is very precise if your have good hardware to support the solution. – Alfonso Tienda Nov 23 '17 at 15:53
  • That solution is written in C++, this question is about C#. – DavidG Nov 23 '17 at 15:55
  • You need your own ntp server, of course, not the public Internet NTP servers. See that you don't need the real time, you need all node's time synchronized, no matter what time are. – Alfonso Tienda Nov 23 '17 at 15:56
  • I will not code the solution, I'm only saying what the solution is. This is the solution. You need to synchronize clocks to synchronize processes. It's the way this is done since the 60's. – Alfonso Tienda Nov 23 '17 at 15:59