Middleware cost optimization metrics