Auto read / write database every second

I am making an auction site that has an automatic bidding system. This system allows people to make applications without being there.

My question is how to implement such a system. I made php files, and everything is ready, I created an html page that is updated every second. This works, but I wonder if there is a better solution.

The second option I tried is to create a Java application that opens a web page every second. This consumes a lot of memory / processor. Also, I think there is a memory leak somewhere.

I am running this application on a dedicated Linux server using centOS and Plesk, so I am sure there are many alternatives.

For example:

  • A cronjob that runs a php file every minute, where the php file loops for a minute with sleep.

  • One php file that loops with 1 second sleep.

  • One cronjob that executes and schedules another cronjob in a second.

  • MySQL is a scheduler, but I don’t know how to implement this, and I heard that it blocks db for other records.

  • I also heard about cli, perl, python scripts, but I am not familiar with any of them.

Please, someone who knows about these options will shed light on this subject. I am looking for a solution that is best suited in terms of speed and memory usage.

If anyone has another alternative solution, I would be happy to hear that as well.

+3
source share
4 answers

, cronjobs , "-", , script, CLI, .

:

  • - .
  • , , .

, script .

, , ? , , - , , 10 . ( , , :)

+2

cron, PHP script . PHP , , ( $_GET, $_POST ).

+2

, - " ", , , , -.

, MySQL PHP , INSERT , , - , .
, .

, , .

, , . .

+1

If you already have a page that is doing the job, you can schedule a cron that invokes the curl command every minute (curl http: //your/page.php ). The only caveat is that you may need to protect your page if it is called from the outside, if this is a problem.

0
source

Source: https://habr.com/ru/post/1722423/


All Articles