A very very minor thing I have been curious about for a while, and I'm finally asking: why do you calculate queue posting times the way you do? For example, if I set my queue to post 3x a day, naively I would expect it to post every 8 hours. But in reality it posts every 6 hours with a 12 hour gap between days. Why complicate the math like that?
Answer:ย Hello @circumference-pie!
Buckle up yโall, itโs story time again!
First: nobody who works at Tumblr right now was a part of the work of planning the default queue implementation, which was more than ten years ago. So the full story behind โWhyย does it work that way?โ has unfortunately been lost to the sands of time. All we can do is tell youย howย it works today and surmise some reasons why. The queue is actually a very clever system and part of how it works explains some of why it works the way it does. Also, there have been attempts to do what you askโwe still have โQueue 2.0โ available inย your Tumblr Labs settings, which tries to get closer to how you expect things to work.
Anyway! How the queue works today is not actuallyย a queueย in the traditional sense. There is no single list of posts that are in โyour queueโ. Instead, when you โAdd to queueโ after creating a post, weโre actuallyย schedulingย it to post at a future time, as if you had used the โSchedule postโ option instead. Weโre just calculating that time on your behalf when you use โAdd to queueโ, based on your settings, and how many other scheduled posts you have already. We use a secondary โindexโ model, called โScheduledPostโ, to keep track of posts you have scheduled on your blog. We do mark the ones that are a part of โyour queueโ, but the data model doesnโt keep one list of your โqueueโ per se.
You can see this in action on your blog, hiding in plain sight. If you add a bunch of posts to your queue, and then schedule a post for a specific future date, youโll seeย bothย in your blogโs โqueueโ list, side by side. Because technically to us, theyโre the same thing: queued posts are really just another kind of scheduled post, relying on the same always-running service to publish scheduled posts across all of Tumblr. Hereโs a fun fact: we typically have about ~14.5 millionย future postsย to publish from this list at any given time and are publishing hundreds of these scheduled posts every second.
So when youโre adding a new post to your queue, what weโre doing behind the scenes is starting at the beginning of your โdayโ, and creating time slots based on your queue settings. If a time slot is already filled, we move on to the next one. Thatโs why the default queue scheduler works how you describeโweโre trying to fill those โslotsโ based on theย startย of the day, rather than trying to divide the calendar day evenly. This just makes it much simpler for us to understand, scale, and predict when our โpeaksโ will be. At peak times, the publish-scheduled-posts service is publishing tens of thousands of posts in a manner of seconds. We did rewrite that post-publishing part of this architecture a few years ago to improve its efficiency and solve a lot of โlost postโ bugs, but we didnโt change how โAdd to queueโ works.
However, the Queue 2.0 projectย available in Labsย was an attempt to change the queue system to work as you expectโinstead of starting at [beginning of day] and creating enough slots to fit [number of slots] every [number of hours], it tries to divide the calendar day into [number of slots] and fit the result back to the original algorithmโs mapping of the day. We never productionized this alternative approach, because it has a few bugs that some blogs hit in extreme cases, and weโve never had time to fully fix them. It also can cause a bit of weirdness when time zones diverge, like with daylight savings time. Also, a lot of people prefer the default algorithm, and we havenโt thought of a nice way to transition everyone from one to the other. So for now, both options exist, and you can choose which algorithm for queue-slot-generating you want to use. We hope that makes sense!ย
While complicated, it is a great example of a system built by engineers to make sense and be scalable and predictable. But sometimes these kinds of systems, while clever, arenโt very intuitive to understand without digging into how they work.
Thanks for your question, and keep โem coming.ย
















