blog

    Introducing NextCron: The Effortless Serverless Background Jobs

    Discover NextCron – A Next Step to The Future of Asynchronous Task Scheduling for Serverless Environments.

    Introducing NextCron: The Effortless Serverless Background Jobs

    We're thrilled to unveil the latest in serverless task management: NextCron is here! 🚀🚀🚀

    NextCron is not just any task scheduler; it's a meticulously crafted system, engineered to bridge your serverless functions seamlessly. Say goodbye to the days when serverless was limited to simple executions. The era of building complex, robust systems with serverless technology has arrived, and NextCron is at its heart.

    The challenge has always been the intricate dance of communication between the multitude of serverless components that constitute a powerful system. While there are existing solutions, many fall short in the serverless arena — they’re either overcomplicated or unsuited for the nuances of stateless environments. NextCron is the answer to these challenges, offering:

    • Universal compatibility, from serverless to edge computing.
    • A no-maintenance, backend-free messaging service.
    • A user-friendly design that’s simple to grasp and integrate.
    • A cost-effective model where expenses scale down to nothing.

    Imagine an e-commerce platform looking to send a confirmation email post-purchase. You have a 'newPurchase' API route and a 'sendEmail' notification service. Directly calling 'sendEmail' from 'newPurchase' could work, but what if it fails? Should your purchase service wait and retry? What if the email service is swamped and unresponsive?

    Enter NextCron. With NextCron, your 'newPurchase' service merely dispatches a request to NextCron. It queues the message, reliably triggering the 'sendEmail' service. If the email service falters, NextCron initiates retries with a strategic backoff approach. This decoupling means that a delay in the 'sendEmail' service doesn't impact 'newPurchase', and updates to either can be made independently, maintaining message format consistency.

    But there’s more. NextCron lets you introduce delays effortlessly. Want to send a review reminder three days post-delivery? Simply set it up. Recurring tasks? Just specify a CRON expression, and NextCron will handle the rest, executing your tasks on a regular schedule.

    Now let’s explore the standout features of NextCron:

    Universal Compatibility

    Gone are the days of pull-based messaging requiring long-running processes. NextCron revolutionizes this by directly pushing messages to your API endpoints. Ideal for serverless architectures, NextCron handles task retries, custom delays, and precise scheduling on your behalf. The only requirement is a publicly accessible HTTP API, making serverless function processing a breeze.

    Cost-Efficiency at Scale

    NextCron's pricing model is as friendly as its user interface. Get started for free with 10,000 requests and scale your operations without breaking the bank. For extensive needs, our subscriptions start at just $9 for 1,000,000 requests, ensuring that as your needs grow, your costs remain manageable. Say hello to transparent pricing and goodbye to hidden fees.

    Immediate Job Execution

    In the fast-paced world of serverless applications, sometimes you need a task to be executed right away. Whether it's sending a welcome email after a user signs up or processing a payment transaction, immediate job execution is crucial for maintaining a fluid user experience.

    For instance, let's say you want to send a welcome email immediately after a user signs up. With NextCron, setting up an immediate job execution for this scenario is simple. Here's how you can configure an immediate job execution with a CURL command:

    curl -X POST https://nextcron.co/api/v1/jobs/publish \
    -H "Content-Type: application/json" \
    -H "Authorization: your-api-token" \
    -d '{
      "topic": "welcome-email",
      "target": "https://your-service-endpoint/send-welcome-email",
      "method": "POST",
      "input": {
        "userEmail": "[email protected]"
      },
      "opts": {}
    }'

    In this example, the topic is set to "welcome-email", which categorizes this job accordingly. The target is the endpoint that processes the email, and the input includes the userEmail of the created user. The opts object is left empty, indicating that the job should be executed immediately with no additional configuration.

    Delayed Job Execution

    There are scenarios where you might want to delay the execution of a task, such as sending a follow-up email a few days after a customer has made a purchase or delaying a notification to avoid interrupting a user during peak activity hours.

    For example, consider you want to send a discount offer 24 hours after a customer's first purchase. Here's how you can schedule this delayed job with NextCron using a CURL command:

    curl -X POST https://nextcron.co/api/v1/jobs/publish \
    -H "Content-Type: application/json" \
    -H "Authorization: your-api-token" \
    -d '{
      "topic": "discount-offer",
      "target": "https://your-service-endpoint/send-discount",
      "method": "POST",
      "input": {
        "customerId": "12345",
        "offerDetails": "20% off on next purchase"
      },
      "opts": {
        "delay": 86400000  # Delay in milliseconds (24 hours)
      }
    }'

    The opts field specifies the delay before the job is executed. In this case, we've set a delay of 86400000 milliseconds, which equates to 24 hours. With this setup, the discount-offer event will trigger your specified target endpoint to send out the offer to the customer after the specified delay has passed.

    Scheduling Recurring Jobs with CRON

    Sometimes your application needs to perform actions on a regular schedule, like generating weekly reports or sending out routine maintenance reminders. NextCron’s CRON job capability allows you to do just that.

    Imagine you want to clear temporary files from your server every Sunday at midnight to ensure smooth operation for the coming week. With NextCron, you can set up a CRON job to handle this weekly task. Here's the CURL command to establish such a schedule:

    curl -X POST https://nextcron.co/api/v1/jobs/publish \
    -H "Content-Type: application/json" \
    -H "Authorization: your-api-token" \
    -d '{
      "topic": "weekly-cleanup",
      "target": "https://your-service-endpoint/cleanup-temp",
      "method": "POST",
      "input": {},
      "opts": {
        "repeat": {
          "cron": "0 0 * * 0"  # CRON expression for every Sunday at midnight
        }
      }
    }'

    In the opts object, the repeat property is used to define the recurrence pattern with a CRON expression. The example provided uses "0 0 0", which corresponds to every week on Sunday at midnight. This setup ensures your weekly-cleanup task calls the target endpoint to perform the cleanup operation like clockwork.

    Explore More with NextCron

    • Retries: Ensure reliable task execution with NextCron’s robust retry mechanisms.
    • Delays: Gain control over task timing with customizable delay options.
    • Scheduling: Maintain the uniqueness of your tasks and avoid redundant processing.
    • Protecting endpoints: Secure your public APIs with our straightforward request signing feature.
    • JavaScript/TypeScript SDK: Streamline your development with our easy-to-use SDKs for JavaScript and TypeScript.

    Next steps

    NextCron is the next step in the evolution of serverless task management. As we proudly launch this initial release, your insights and feedback are crucial to shaping its future. For more detailed information and usage tips, dive into the NextCron documentation.

    Want to stay updated and engage with the community? Follow me on Twitter @feldbarcelospro for the latest news, updates, and discussions around NextCron and serverless technologies.

    NextCron

    Background jobs reimagined.
    Ready to start building?

    Unleash the full power of background jobs with NextCron. Effortless integration in just minutes!