DEV Community

Francis Oyakhire
Francis Oyakhire

Posted on

Publishing Pipeline Scheduled vs Immediate

This week’s focus on log analysis tools reminded us of the importance of infrastructure that works reliably in the background - and that’s exactly what we’re building at Apex Grid. Just as log analysis tools help us understand the health of our systems, our publishing pipeline needs to be robust enough to handle both scheduled and immediate content delivery without breaking the user experience.

At Apex Grid, we run a hybrid publishing pipeline that balances the need for immediate content delivery with the strategic value of scheduling posts for optimal user engagement. For example, we use Postiz to schedule social media posts for specific timezones, ensuring that our audience sees content when it matters most. Meanwhile, long-form articles like this one are published on a cron-fire schedule, hitting our platform at regular intervals. This approach allows us to maintain a consistent content rhythm while still tailoring engagement tactics to different platforms.

The challenge arises when these two workflows intersect - specifically, when the same content is published both immediately and scheduled for later. A key point of friction is the canonical URL. For example, a post published immediately may have one URL structure, while the same content scheduled for later might be routed through a different endpoint, leading to duplicate content and broken links. To solve this, we’ve implemented a centralized content routing system that assigns a single, stable canonical URL to every piece of content, regardless of when or where it’s published.

Here’s a simplified version of how we manage this in our backend:

from flask import Flask, request, redirect, url_for
import uuid

app = Flask(__name__)

# In-memory store for content metadata
content_store = {}

@app.route('/publish', methods=['POST'])
def publish_content():
    data = request.json
    content_id = str(uuid.uuid4())
    content_store[content_id] = {
        'title': data['title'],
        'body': data['body'],
        'scheduled_time': data.get('scheduled_time'),
        'canonical_url': f"https://apexgrid.dev/content/{content_id}"
    }
    return {'canonical_url': content_store[content_id]['canonical_url']}, 201

@app.route('/content/<content_id>')
def get_content(content_id):
    if content_id in content_store:
        return content_store[content_id]['body'], 200
    return "Content not found", 404

if __name__ == '__main__':
    app.run()
Enter fullscreen mode Exit fullscreen mode

This code snippet shows how we assign a unique canonical URL to each piece of content as it’s published. Whether the content is scheduled or published immediately, the canonical URL remains consistent. This approach ensures that search engines and users always see the same URL for the same content, no matter the delivery method.

However, this abstraction isn’t without tradeoffs. Managing a centralized content store adds complexity to our system. It requires careful coordination between our scheduling systems, our content delivery networks, and our analytics pipelines. Additionally, we’ve had to invest in robust versioning and caching strategies to ensure that updates to scheduled content don’t inadvertently overwrite or break already-published posts.

Looking ahead, we’re exploring ways to further decouple our scheduling and immediate publishing systems while maintaining the same level of consistency. One idea is to introduce a lightweight content graph that can dynamically route requests to the correct version of a post based on time, platform, and user context. We’re also evaluating how to better integrate with third-party platforms like Postiz to ensure that scheduled posts are automatically mirrored with the same canonical URL structure as our immediate content.

What do you think about the tradeoffs between centralized and decentralized content routing in hybrid publishing pipelines? Have you encountered similar challenges in your own projects?

Top comments (0)