Field Notes

Patterns, laws and paradigms collected in production, with the scars to prove them.

$ currently exploring:Model Context Protocol (MCP)GoLLM agent orchestration

Reusable, named solutions to recurring design problems, and a shared vocabulary for structure.refactoring.guru

// One client per Lambda container. A fresh client
// per invocation exhausts the RDS connection pool.
let prisma: PrismaClient | undefined;

export const getPrisma = (): PrismaClient => {
  prisma ??= new PrismaClient();
  return prisma;
};

// field noteA Lambda that opened a fresh database client on every invocation melted our RDS connection limit during a traffic spike. One cached instance per container fixed it in four lines.

$ verdict:Use sparingly. In TypeScript a module export is already a singleton; in Go, sync.Once is the whole pattern.