Created
October 15, 2025 21:11
-
-
Save davidegreenwald/b4828f74e76d38d515860ad6bce07856 to your computer and use it in GitHub Desktop.
memcached-rfc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Creates a memcached statefulset and headless service | |
| # Use statefulsets and the headless service for pod-level DNS for future-proofing - | |
| # If adding more pods, we can use Python hashing to spread queries between pods | |
| # at the service name if needed for HA. | |
| # | |
| # expected use is 1 pod | |
| # Also: | |
| # - Sets RAM, threads, connections | |
| # - Sets up Datadog metrics | |
| # - not sure if we need liveness probes here | |
| # removes some extra flags such as -modern from the monolith deployment which | |
| # are likely unnecessary for general use | |
| apiVersion: apps/v1 | |
| kind: Statefulset | |
| metadata: | |
| name: memcached | |
| labels: | |
| app: memcached | |
| tags.datadoghq.com/env: "prod" | |
| tags.datadoghq.com/service: # set the same as the app service name | |
| tags.datadoghq.com/version: "kustomize-managed" # Kustomize sets this | |
| spec: | |
| replicas: 1 | |
| selector: | |
| matchLabels: | |
| app: memcached | |
| serviceName: memcached | |
| template: | |
| metadata: | |
| annotations: | |
| # get memcached metrics | |
| ad.datadoghq.com/memcached.checks: | | |
| { | |
| "mcache": { | |
| "init_config": {}, | |
| "instances": [{"url": "%%host%%"}] | |
| } | |
| } | |
| labels: | |
| app: memcached | |
| tags.datadoghq.com/env: "prod" | |
| tags.datadoghq.com/service: # set the same as the app service name | |
| tags.datadoghq.com/version: "kustomize-managed" # kustomize sets this | |
| spec: | |
| containers: | |
| - name: memcached | |
| image: memcached:1.6.39 # use semantic versions, include in maintenance plan | |
| command: | |
| - memcached | |
| - -m 1000 # default 64 MB. 1-3 GB should be fine for most cases. More is not better as available space will fill. | |
| - -t 4 # default 4 threads, more shouldn't be needed - add CPU cores if so | |
| - -c 4096 # default 1024 connections - more = more RAM. Monitor for hitting limit. | |
| livenessProbe: | |
| initialDelaySeconds: 30 | |
| tcpSocket: | |
| port: memcached | |
| timeoutSeconds: 5 | |
| ports: | |
| - containerPort: 11211 | |
| name: memcached | |
| readinessProbe: | |
| initialDelaySeconds: 5 | |
| tcpSocket: | |
| port: memcached | |
| timeoutSeconds: 1 | |
| resources: | |
| # RAM should be slightly more than `command` -m flag allotment | |
| requests: | |
| cpu: 500m | |
| memory: 1.25Gi | |
| limits: | |
| memory: 1.25Gi | |
| nodeSelector: | |
| # run on spot in us-west-2a | |
| # this means the pod will occasionally be removed | |
| kubernetes.io/arch: arm64 | |
| topology.kubernetes.io/zone: us-west-2a # testing single-AZ for bandwidth costs | |
| --- | |
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: memcached | |
| labels: | |
| app: memcached | |
| spec: | |
| clusterIP: None | |
| selector: | |
| app: memcached | |
| ports: | |
| - name: memcached | |
| protocol: TCP | |
| port: 11211 | |
| targetPort: 11211 | |
| --- | |
| # we should have a PDB here for additional safety |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment