DEV Community

Cover image for Speed Up Your Go App Startup with Parallel Dependency Injection
mazrean
mazrean

Posted on

Speed Up Your Go App Startup with Parallel Dependency Injection

I built Kessoku to solve a simple problem: Go apps start too slowly.

Your app probably initializes services like this:

DB (300ms) → Cache (200ms) → Auth (100ms) = 600ms 😴 
Enter fullscreen mode Exit fullscreen mode

Kessoku runs them in parallel:

DB (300ms) ┐ Cache (200ms) ├─ = 300ms 🚀 Auth (100ms) ┘ 
Enter fullscreen mode Exit fullscreen mode

Quick Example

//go:generate go tool kessoku $GOFILE var _ = kessoku.Inject[*App]("InitApp", kessoku.Async(kessoku.Provide(NewDB)), // These run kessoku.Async(kessoku.Provide(NewCache)), // at the same kessoku.Async(kessoku.Provide(NewAuth)), // time! kessoku.Provide(NewApp), ) 
Enter fullscreen mode Exit fullscreen mode

Get Started

go get -tool github.com/mazrean/kessoku/cmd/kessoku 
Enter fullscreen mode Exit fullscreen mode

That's it. Your app now starts faster.

Why Kessoku?

  • Compile-time: Zero runtime overhead (unlike uber/fx)
  • Automatic: Just add Async() to parallelize
  • Compatible: Drop-in replacement for google/wire

Perfect for microservices, serverless functions, or any app with multiple slow initializations.


github.com/mazrean/kessoku

Top comments (0)