Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Event-driven serverless functions with Next.js and Inngest

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Cargando en…3
×

Eche un vistazo a continuación

1 de 17 Anuncio

Más Contenido Relacionado

Similares a Event-driven serverless functions with Next.js and Inngest (20)

Más reciente (20)

Anuncio

Event-driven serverless functions with Next.js and Inngest

  1. 1. Event-driven serverless functions with Next.js and Inngest Dan Farrelly - Co-founder + CTO - Inngest Detroit React/Node Meetup - Jan 2023
  2. 2. Problem: Background functions in serverless applications ● Serverless API functions are great and are now well supported on amazing platforms like Vercel or Netlify. ● Frameworks - They’re synchronous only: ○ Next.js ○ Remix ○ Fresh (Deno) ○ Cloudflare Pages Functions ○ RedwoodJS, Nuxt.js, etc… ● What happens when you need to run something asynchronously? ● Serverless vs. ServerFULL - no process to poll a queue ● This usually forces someone to eject a framework
  3. 3. Ways to run background functions/jobs You need an abstraction to pass data from the initiator to the processor: ● Queue + Worker ● Event Stream + Consumer ● Database + Cron (pretty much a queue + worker) ● Inngest ✨
  4. 4. Comparison: Queues + Workers ● Messages ● Long running workers & polling for messages - mostly idle ○ Not severless friendly ● 1 Message + 1 worker = No fan-out ● Decide how to handle retries + dead letter queues ● No message history for replay/complex system recovery
  5. 5. Comparison: Event Stream + Consumer ● Events ● Consumers read events in order ● Consumers can read same data (enables fan-out) ● Define “topics” and “partitions” ● Concurrency handled through more partitions + consumers ● Must handle backpressure (maybe with a queue!)
  6. 6. Comparison: Inngest ✨ ● Best of both worlds under the hood: Event Stream + Queue ● Not just pipes, but an entire solution for anything async ● Retries built in ● Concurrency and idempotency controls ● Step functions + complex workflows enabled via SDK and Inngest storing function run state ● No configuration - just send events ● Full event history + function logs
  7. 7. What is Inngest?
  8. 8. What is Inngest? Inngest is a developer platform that enables you to run reliable serverless background functions, triggered by events or cron, deployed to any platform.
  9. 9. Inngest is a developer platform that enables you to run reliable serverless background functions, triggered by events or cron, deployed to any platform. What is Inngest? ● Serverless functions ● Background ● Reliable ● Events ● Deploy to any platform
  10. 10. How Inngest works?
  11. 11. A basic Inngest function - Send Welcome Email
  12. 12. step.run() ● Breaks up long running functions into short steps ● Each run as a separate HTTP request ● Each is individually retried if it fails (Reliability) step.sleep() ● Inngest resumes your function after the specified sleep period Adding extra steps and sleep - Onboarding drip campaign
  13. 13. step.waitForEvent() ● Create dynamic functions that wait for additional inputs. ● Pause a function until another event is received. ● If timeout occurs before matching event is received, the return value is `null`. Coordinating between events - Dynamic drip campaign
  14. 14. What else can I do with Inngest? ● Run functions on a schedule - Cron jobs ● Schedule code to run in the future ○ step.sleepUntil(“2023-02-01 18:00:00”) ● Use events to fan-out work to different functions - run in parallel ● Process high-volume webhooks (Webhooks = events) ● And much more…
  15. 15. DX first - Inngest Dev Server
  16. 16. 󰞦 Demo time 🔥
  17. 17. Any questions? inngest.com/docs inngest.com/careers github.com/inngest

×