Field Notes

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

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

Design patterns: reusable, named solutions to recurring design problems — 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.