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 (e.g. a Rake task) to do the job.