简体   繁体   中英

Pages stop responding with ruby on rails and mysql

I'm using Thin server + Ruby on Rails + Mysql, and I have several cronjobs that do heavy processing with the database every hour (scripts take about 1-2 minutes to finish).

When the cronjobs run, the website stops loading, and only responds AFTER cronjob finishes.

So my question is, how can I make everything independent, asynchronous or parallel, so that when cronjobs are running the website loads normally.

Any links to guides, or general advice much appreciated.

Update:

I'm sorry I can't share the code of cronjob, but basically it does several thousands of requests like:

SELECT 1 AS one FROM `table` WHERE `table`.`type_id` = BINARY '1251625345_4146645145056' LIMIT 1

and then several thousand of Inserts if the previous one returns null (that means the entry doesnt exist)

Does your cron job ask the Rails app to do those selects/inserts?

If so,

Thin is a single-threaded web server. It can't handle more than one request simultaneously. You cronjob should start another Ruby process (eg a Rake task) to do the job.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM