{
  "openapi": "3.1.1",
  "info": {
    "title": "Serverless Performance Explorer API",
    "version": "1.0.0",
    "summary": "Lambda REPORT lines → cold-start rate, p50/p95/p99, memory right-sizing and cost per 1M calls.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://serverlessperformanceexplorer.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Lambda REPORT lines → cold-start rate, p50/p95/p99, memory right-sizing and cost per 1M calls.",
        "description": "Paste AWS Lambda REPORT log lines, JSON platform.report records or a CSV/Logs Insights export. Get cold-start rate, init and duration percentiles, memory utilisation with a right-sizing suggestion, and the cost per 1 million invocations on x86_64 and arm64 using the public Lambda prices (overridable).\n\nMethodology:\n- Each REPORT line (plain text or JSON \"platform.report\") yields Duration, Billed Duration, Memory Size, Max Memory Used and, on cold starts, Init Duration (or SnapStart Restore Duration). \"Status: timeout|error\" and \"Task timed out after\" lines mark failed invocations.\n- Cold-start rate = invocations with Init/Restore Duration ÷ all invocations. Percentiles use the nearest-rank method on the observed values.\n- GB-seconds per invocation = Billed Duration (s) × Memory Size (MB) ÷ 1024. If Billed Duration is missing it is estimated as ceil(Duration + Init) because INIT is billed for on-demand functions since 1 Aug 2025.\n- Cost per 1M invocations = price per 1M requests + 1,000,000 × mean GB-s × price per GB-s, for x86_64 and arm64 (first pricing tier, no free tier).\n- Right-sizing: suggested memory = peak Max Memory Used × (1 + headroom), rounded up to 64 MB (128–10,240 MB). Increase if peak use ≥ 90 % of the configured size; decrease if the suggestion is ≤ 75 % of it; otherwise keep. Cost estimates assume the billed duration does not change with memory (CPU scales with memory, so verify).\n- CloudWatch Logs Insights exports report @memorySize/@maxMemoryUsed in bytes; values above 100,000 are converted to MB (10^6 bytes).",
        "tags": [
          "devcloud"
        ],
        "x-mcp-tool": "serverless_performance_explorer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServerlessPerformanceExplorerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Two functions from CloudWatch REPORT lines",
                  "value": {
                    "logs": "=== function: checkout-api ===\n2026-10-12T09:00:00.000Z REPORT RequestId: 1a2b3c00-4c1d-4e2f-9a0b-0c0ffee00000\tDuration: 323.82 ms\tBilled Duration: 788 ms\tMemory Size: 1024 MB\tMax Memory Used: 171 MB\tInit Duration: 463.87 ms\n2026-10-12T09:02:00.000Z REPORT RequestId: 1a2b3c01-4c1d-4e2f-9a0b-0c0ffee01eef\tDuration: 97.23 ms\tBilled Duration: 98 ms\tMemory Size: 1024 MB\tMax Memory Used: 176 MB\n2026-10-12T09:04:00.000Z REPORT RequestId: 1a2b3c02-4c1d-4e2f-9a0b-0c0ffee03dde\tDuration: 69.75 ms\tBilled Duration: 70 ms\tMemory Size: 1024 MB\tMax Memory Used: 184 MB\n2026-10-12T09:06:00.000Z REPORT RequestId: 1a2b3c03-4c1d-4e2f-9a0b-0c0ffee05ccd\tDuration: 92.92 ms\tBilled Duration: 93 ms\tMemory Size: 1024 MB\tMax Memory Used: 152 MB\n2026-10-12T09:08:00.000Z REPORT RequestId: 1a2b3c04-4c1d-4e2f-9a0b-0c0ffee07bbc\tDuration: 97.84 ms\tBilled Duration: 98 ms\tMemory Size: 1024 MB\tMax Memory Used: 158 MB\n2026-10-12T09:10:00.000Z REPORT RequestId: 1a2b3c05-4c1d-4e2f-9a0b-0c0ffee09aab\tDuration: 49.60 ms\tBilled Duration: 50 ms\tMemory Size: 1024 MB\tMax Memory Used: 189 MB\n2026-10-12T09:12:00.000Z REPORT RequestId: 1a2b3c06-4c1d-4e2f-9a0b-0c0ffee0b99a\tDuration: 41.54 ms\tBilled Duration: 42 ms\tMemory Size: 1024 MB\tMax Memory Used: 165 MB\n2026-10-12T09:14:00.000Z REPORT RequestId: 1a2b3c07-4c1d-4e2f-9a0b-0c0ffee0d889\tDuration: 39.82 ms\tBilled Duration: 40 ms\tMemory Size: 1024 MB\tMax Memory Used: 152 MB\n2026-10-12T09:16:00.000Z REPORT RequestId: 1a2b3c08-4c1d-4e2f-9a0b-0c0ffee0f778\tDuration: 78.42 ms\tBilled Duration: 79 ms\tMemory Size: 1024 MB\tMax Memory Used: 186 MB\n2026-10-12T09:18:00.000Z REPORT RequestId: 1a2b3c09-4c1d-4e2f-9a0b-0c0ffee11667\tDuration: 86.57 ms\tBilled Duration: 630 ms\tMemory Size: 1024 MB\tMax Memory Used: 152 MB\tInit Duration: 543.42 ms\n2026-10-12T09:20:00.000Z REPORT RequestId: 1a2b3c0a-4c1d-4e2f-9a0b-0c0ffee13556\tDuration: 75.09 ms\tBilled Duration: 76 ms\tMemory Size: 1024 MB\tMax Memory Used: 169 MB\n2026-10-12T09:22:00.000Z REPORT RequestId: 1a2b3c0b-4c1d-4e2f-9a0b-0c0ffee15445\tDuration: 300.23 ms\tBilled Duration: 301 ms\tMemory Size: 1024 MB\tMax Memory Used: 185 MB\n2026-10-12T09:24:00.000Z REPORT RequestId: 1a2b3c0c-4c1d-4e2f-9a0b-0c0ffee17334\tDuration: 42.13 ms\tBilled Duration: 43 ms\tMemory Size: 1024 MB\tMax Memory Used: 182 MB\n2026-10-12T09:26:00.000Z REPORT RequestId: 1a2b3c0d-4c1d-4e2f-9a0b-0c0ffee19223\tDuration: 46.78 ms\tBilled Duration: 47 ms\tMemory Size: 1024 MB\tMax Memory Used: 151 MB\n2026-10-12T09:28:00.000Z REPORT RequestId: 1a2b3c0e-4c1d-4e2f-9a0b-0c0ffee1b112\tDuration: 80.99 ms\tBilled Duration: 81 ms\tMemory Size: 1024 MB\tMax Memory Used: 179 MB\n2026-10-12T09:30:00.000Z REPORT RequestId: 1a2b3c0f-4c1d-4e2f-9a0b-0c0ffee1d001\tDuration: 89.79 ms\tBilled Duration: 90 ms\tMemory Size: 1024 MB\tMax Memory Used: 182 MB\n2026-10-12T09:32:00.000Z REPORT RequestId: 1a2b3c10-4c1d-4e2f-9a0b-0c0ffee1eef0\tDuration: 88.15 ms\tBilled Duration: 89 ms\tMemory Size: 1024 MB\tMax Memory Used: 179 MB\n2026-10-12T09:34:00.000Z REPORT RequestId: 1a2b3c11-4c1d-4e2f-9a0b-0c0ffee20ddf\tDuration: 40.17 ms\tBilled Duration: 512 ms\tMemory Size: 1024 MB\tMax Memory Used: 156 MB\tInit Duration: 471.02 ms\n2026-10-12T09:36:00.000Z REPORT RequestId: 1a2b3c12-4c1d-4e2f-9a0b-0c0ffee22cce\tDuration: 77.53 ms\tBilled Duration: 78 ms\tMemory Size: 1024 MB\tMax Memory Used: 165 MB\n2026-10-12T09:38:00.000Z REPORT RequestId: 1a2b3c13-4c1d-4e2f-9a0b-0c0ffee24bbd\tDuration: 55.96 ms\tBilled Duration: 56 ms\tMemory Size: 1024 MB\tMax Memory Used: 181 MB\n2026-10-12T09:40:00.000Z REPORT RequestId: 1a2b3c14-4c1d-4e2f-9a0b-0c0ffee26aac\tDuration: 56.77 ms\tBilled Duration: 57 ms\tMemory Size: 1024 MB\tMax Memory Used: 184 MB\n2026-10-12T09:42:00.000Z REPORT RequestId: 1a2b3c15-4c1d-4e2f-9a0b-0c0ffee2899b\tDuration: 71.49 ms\tBilled Duration: 72 ms\tMemory Size: 1024 MB\tMax Memory Used: 158 MB\n2026-10-12T09:44:00.000Z REPORT RequestId: 1a2b3c16-4c1d-4e2f-9a0b-0c0ffee2a88a\tDuration: 315.72 ms\tBilled Duration: 316 ms\tMemory Size: 1024 MB\tMax Memory Used: 172 MB\n2026-10-12T09:46:00.000Z REPORT RequestId: 1a2b3c17-4c1d-4e2f-9a0b-0c0ffee2c779\tDuration: 62.91 ms\tBilled Duration: 63 ms\tMemory Size: 1024 MB\tMax Memory Used: 161 MB\n=== function: image-resize ===\nREPORT RequestId: 1a2b3c64-4c1d-4e2f-9a0b-0c0ffeec155c\tDuration: 2076.37 ms\tBilled Duration: 3017 ms\tMemory Size: 512 MB\tMax Memory Used: 454 MB\tInit Duration: 940.16 ms\nREPORT RequestId: 1a2b3c65-4c1d-4e2f-9a0b-0c0ffeec344b\tDuration: 1904.43 ms\tBilled Duration: 1905 ms\tMemory Size: 512 MB\tMax Memory Used: 471 MB\nREPORT RequestId: 1a2b3c66-4c1d-4e2f-9a0b-0c0ffeec533a\tDuration: 1459.25 ms\tBilled Duration: 1460 ms\tMemory Size: 512 MB\tMax Memory Used: 470 MB\nREPORT RequestId: 1a2b3c67-4c1d-4e2f-9a0b-0c0ffeec7229\tDuration: 1232.30 ms\tBilled Duration: 1233 ms\tMemory Size: 512 MB\tMax Memory Used: 436 MB\nREPORT RequestId: 1a2b3c68-4c1d-4e2f-9a0b-0c0ffeec9118\tDuration: 1727.80 ms\tBilled Duration: 1728 ms\tMemory Size: 512 MB\tMax Memory Used: 466 MB\nREPORT RequestId: 1a2b3c69-4c1d-4e2f-9a0b-0c0ffeecb007\tDuration: 1536.59 ms\tBilled Duration: 1537 ms\tMemory Size: 512 MB\tMax Memory Used: 450 MB\nREPORT RequestId: 1a2b3c6a-4c1d-4e2f-9a0b-0c0ffeeccef6\tDuration: 6003.11 ms\tBilled Duration: 6004 ms\tMemory Size: 512 MB\tMax Memory Used: 461 MB\tStatus: timeout\nREPORT RequestId: 1a2b3c6b-4c1d-4e2f-9a0b-0c0ffeecede5\tDuration: 1011.51 ms\tBilled Duration: 1986 ms\tMemory Size: 512 MB\tMax Memory Used: 444 MB\tInit Duration: 974.24 ms\nREPORT RequestId: 1a2b3c6c-4c1d-4e2f-9a0b-0c0ffeed0cd4\tDuration: 1068.91 ms\tBilled Duration: 1069 ms\tMemory Size: 512 MB\tMax Memory Used: 489 MB\nREPORT RequestId: 1a2b3c6d-4c1d-4e2f-9a0b-0c0ffeed2bc3\tDuration: 1745.42 ms\tBilled Duration: 1746 ms\tMemory Size: 512 MB\tMax Memory Used: 473 MB",
                    "architecture": "x86_64",
                    "monthlyInvocations": 5000000
                  }
                },
                "example2": {
                  "summary": "CSV export (arm64, cold starts with billed INIT)",
                  "value": {
                    "logs": "function,timestamp,requestId,duration,billedDuration,memorySize,maxMemoryUsed,initDuration\norders-worker,2026-10-12T08:00:00Z,r1,212.4,640,256,98,427.1\norders-worker,2026-10-12T08:00:05Z,r2,188.0,188,256,101,\norders-worker,2026-10-12T08:00:09Z,r3,176.9,177,256,99,\norders-worker,2026-10-12T08:00:12Z,r4,240.3,241,256,104,\norders-worker,2026-10-12T08:01:30Z,r5,201.7,202,256,103,\norders-worker,2026-10-12T08:02:00Z,r6,195.2,196,256,100,\norders-worker,2026-10-12T08:09:00Z,r7,230.8,705,256,97,473.6\norders-worker,2026-10-12T08:09:02Z,r8,182.5,183,256,102,",
                    "architecture": "arm64"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerlessPerformanceExplorerResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ServerlessPerformanceExplorerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "logs": {
            "title": "REPORT lines or CSV",
            "description": "CloudWatch REPORT lines, JSON log-format platform.report records, or CSV with columns like requestId,duration,billedDuration,memorySize,maxMemoryUsed,initDuration[,function,timestamp]. Separate functions with \"=== function: name ===\".",
            "type": "string",
            "maxLength": 400000
          },
          "file": {
            "title": "Or upload a log/CSV file",
            "type": "object",
            "description": "Upload as {filename, contentType?, contentBase64}. Max 4096 KiB. Accepts .txt,.log,.csv,.json,text/plain,text/csv.",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "architecture": {
            "title": "Current architecture",
            "type": "string",
            "enum": [
              "x86_64",
              "arm64"
            ],
            "default": "x86_64"
          },
          "priceGbSecondX86": {
            "title": "Price per GB-second (x86_64)",
            "description": "Default: us-east-1 first tier, verified 2026-10-14.",
            "type": "number",
            "minimum": 0,
            "default": 0.0000166667,
            "x-unit": "USD/GB-s"
          },
          "priceGbSecondArm": {
            "title": "Price per GB-second (arm64)",
            "type": "number",
            "minimum": 0,
            "default": 0.0000133334,
            "x-unit": "USD/GB-s"
          },
          "pricePerMillionRequests": {
            "title": "Price per 1M requests",
            "type": "number",
            "minimum": 0,
            "default": 0.2,
            "x-unit": "USD"
          },
          "monthlyInvocations": {
            "title": "Monthly invocations (optional)",
            "description": "Adds a monthly cost estimate (free tier not deducted).",
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "headroomPercent": {
            "title": "Memory headroom",
            "description": "Added to the peak observed memory when suggesting a size.",
            "type": "number",
            "minimum": 0,
            "maximum": 200,
            "default": 20,
            "x-unit": "%"
          }
        },
        "required": []
      },
      "ServerlessPerformanceExplorerResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "invocations",
              "functions",
              "prices"
            ],
            "properties": {
              "invocations": {
                "type": "integer",
                "minimum": 0
              },
              "functions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "function",
                    "invocations",
                    "coldStarts",
                    "coldStartRate",
                    "initP50Ms",
                    "initP95Ms",
                    "initMaxMs",
                    "durationP50Ms",
                    "durationP95Ms",
                    "durationP99Ms",
                    "durationMaxMs",
                    "durationMeanMs",
                    "billedMeanMs",
                    "memorySizeMb",
                    "memorySizesSeen",
                    "maxMemoryUsedP95Mb",
                    "maxMemoryUsedMaxMb",
                    "memoryUtilisationP95",
                    "memoryUtilisationMax",
                    "errors",
                    "timeouts",
                    "gbSecondsPerInvocation",
                    "costPer1M",
                    "monthlyCost",
                    "recommendation",
                    "initBilled"
                  ],
                  "properties": {
                    "function": {
                      "type": "string"
                    },
                    "invocations": {
                      "type": "integer",
                      "minimum": 1
                    },
                    "coldStarts": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "coldStartRate": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "initP50Ms": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "initP95Ms": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "initMaxMs": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "durationP50Ms": {
                      "type": "number"
                    },
                    "durationP95Ms": {
                      "type": "number"
                    },
                    "durationP99Ms": {
                      "type": "number"
                    },
                    "durationMaxMs": {
                      "type": "number"
                    },
                    "durationMeanMs": {
                      "type": "number"
                    },
                    "billedMeanMs": {
                      "type": "number"
                    },
                    "memorySizeMb": {
                      "type": "number"
                    },
                    "memorySizesSeen": {
                      "type": "array",
                      "items": {
                        "type": "number"
                      }
                    },
                    "maxMemoryUsedP95Mb": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "maxMemoryUsedMaxMb": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "memoryUtilisationP95": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "memoryUtilisationMax": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "errors": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "timeouts": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "gbSecondsPerInvocation": {
                      "type": "number",
                      "minimum": 0
                    },
                    "costPer1M": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "x86_64",
                        "arm64",
                        "requests"
                      ],
                      "properties": {
                        "x86_64": {
                          "type": "number"
                        },
                        "arm64": {
                          "type": "number"
                        },
                        "requests": {
                          "type": "number"
                        }
                      }
                    },
                    "monthlyCost": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "additionalProperties": false,
                      "properties": {
                        "x86_64": {
                          "type": "number"
                        },
                        "arm64": {
                          "type": "number"
                        }
                      }
                    },
                    "recommendation": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "action",
                        "memoryMb",
                        "reason",
                        "estCostPer1M",
                        "estSavingPct"
                      ],
                      "properties": {
                        "action": {
                          "type": "string",
                          "enum": [
                            "decrease",
                            "increase",
                            "keep",
                            "unknown"
                          ]
                        },
                        "memoryMb": {
                          "type": "number"
                        },
                        "reason": {
                          "type": "string"
                        },
                        "estCostPer1M": {
                          "type": "number"
                        },
                        "estSavingPct": {
                          "type": "number"
                        }
                      }
                    },
                    "initBilled": {
                      "type": "string",
                      "enum": [
                        "included",
                        "not-included",
                        "unknown"
                      ]
                    }
                  }
                }
              },
              "prices": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "gbSecondX86",
                  "gbSecondArm",
                  "perMillionRequests",
                  "defaults"
                ],
                "properties": {
                  "gbSecondX86": {
                    "type": "number"
                  },
                  "gbSecondArm": {
                    "type": "number"
                  },
                  "perMillionRequests": {
                    "type": "number"
                  },
                  "defaults": {
                    "type": "boolean"
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}