Create and delay task for 24 hours [closed]

I’m trying to come up with a sane architecture to delay a task for 24 hours. So far I’ve thought of:

  • unix cron job, but this will not be able to take the load we give it, since we will have many thousands of delayed tasks per day
  • Use RabbitMQ with dead letter exchange, however, this is a hack and being a hack is riddled with problems – impossible to monitor without mutilating the messages, etc.
  • Other solutions I’ve come up with are poll based, e.g., insert task into MySQL and have a poller responsible
  • Amazon SQS only supports up to 15 minute delays. I could write a punt loop for # of delays, btu this is already reinventing the wheel way too much. Plus using SQS this would get expensive as we pay per message.
  • Redis possibly…? have not heavily investigated this. I know Memcached is not appropriate as it won’t really guarantee persistence that long.

What existing technology is good for this? I don’t want to reinvent the wheel here, given that I’m pretty sure I’m not working on the first software product that requires performing a task tomorrow. Thus far I’ve been database driving things.

1

I believe your first instinct is the best one – in that it is where you should look for the answer. The early versions of cron was a polling approach (every minute, check to see if anything should be run). A later version made use of a discrete event simulator. The article that lead to this version of cron is titled “An efficient data structure for the simulation event set”. Reading this (it is several pages long) may help you in understanding of the algorithm and how to reimplement it yourself.

At any given time, you know all of the events that will happen within the next 24 hours. Each time the process runs to deal with something, it looks at the head of the queue to see how long it needs to sleep – it then sleeps that long, and launches another thread or process to deal with that job, and repeats (read the head, sleep, fork, read head, …).

Internally, this is how cron works.

The question then becomes how do you want to update and persist this data structure. Writing the data to a database or to a file on a file system seem to be the two best approaches for this – being ways that are simple to access from a multitude of different approaches.

I would not try to persist the data in a message queue as it really isn’t meant for that.

I don’t have much experience with job scheduling and batch processing, but I do know Quartz is an enterprise level tool that let’s you schedule thousands of jobs if needed and it lets you assign system resources (cores/threads), etc. You might want to have a look at it if you are willing to create (or already have) a Java solution.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Create and delay task for 24 hours [closed]

I’m trying to come up with a sane architecture to delay a task for 24 hours. So far I’ve thought of:

  • unix cron job, but this will not be able to take the load we give it, since we will have many thousands of delayed tasks per day
  • Use RabbitMQ with dead letter exchange, however, this is a hack and being a hack is riddled with problems – impossible to monitor without mutilating the messages, etc.
  • Other solutions I’ve come up with are poll based, e.g., insert task into MySQL and have a poller responsible
  • Amazon SQS only supports up to 15 minute delays. I could write a punt loop for # of delays, btu this is already reinventing the wheel way too much. Plus using SQS this would get expensive as we pay per message.
  • Redis possibly…? have not heavily investigated this. I know Memcached is not appropriate as it won’t really guarantee persistence that long.

What existing technology is good for this? I don’t want to reinvent the wheel here, given that I’m pretty sure I’m not working on the first software product that requires performing a task tomorrow. Thus far I’ve been database driving things.

1

I believe your first instinct is the best one – in that it is where you should look for the answer. The early versions of cron was a polling approach (every minute, check to see if anything should be run). A later version made use of a discrete event simulator. The article that lead to this version of cron is titled “An efficient data structure for the simulation event set”. Reading this (it is several pages long) may help you in understanding of the algorithm and how to reimplement it yourself.

At any given time, you know all of the events that will happen within the next 24 hours. Each time the process runs to deal with something, it looks at the head of the queue to see how long it needs to sleep – it then sleeps that long, and launches another thread or process to deal with that job, and repeats (read the head, sleep, fork, read head, …).

Internally, this is how cron works.

The question then becomes how do you want to update and persist this data structure. Writing the data to a database or to a file on a file system seem to be the two best approaches for this – being ways that are simple to access from a multitude of different approaches.

I would not try to persist the data in a message queue as it really isn’t meant for that.

I don’t have much experience with job scheduling and batch processing, but I do know Quartz is an enterprise level tool that let’s you schedule thousands of jobs if needed and it lets you assign system resources (cores/threads), etc. You might want to have a look at it if you are willing to create (or already have) a Java solution.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật