Skip to content

Commit df2ed82

Browse files
committed
Production redis settings
1 parent 349d919 commit df2ed82

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

deployment/services/redis.ts

+13
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ export function deployRedis(input: { environment: Environment }) {
2828
memory: '100Mi',
2929
cpu: '50m',
3030
},
31+
args: [
32+
// When maxmemory is exceeded, the maxmemory-policy is applied.
33+
// This maxmemory should be 60-70% of the available memory.
34+
'--maxmemory', input.environment.isProduction ? '2048mb' : '32m',
35+
// This keeps the most recently used keys. AKA Act like a cache!
36+
'--maxmemory-policy', 'allkeys-lru',
37+
// Lazy memory eviction is more performant, but could cause memory
38+
// to exceed available space if not enough room is given. This is why
39+
// the 60-70% is crucial.
40+
'--lazyfree-lazy-eviction', 'yes',
41+
// This disables snapshotting to save cpu and reduce latency spikes
42+
'--save', '""',
43+
],
3144
});
3245

3346
const host = serviceLocalHost(redisApi.service);

deployment/utils/redis.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as k8s from '@pulumi/kubernetes';
22
import * as kx from '@pulumi/kubernetesx';
3-
import { Output } from '@pulumi/pulumi';
3+
import { Output, Input } from '@pulumi/pulumi';
44
import { getLocalComposeConfig } from './local-config';
55
import { normalizeEnv, PodBuilder } from './pod-builder';
66

@@ -14,7 +14,7 @@ export class Redis {
1414
},
1515
) {}
1616

17-
deploy({ limits }: { limits: k8s.types.input.core.v1.ResourceRequirements['limits'] }) {
17+
deploy({ limits, args }: { limits: k8s.types.input.core.v1.ResourceRequirements['limits'], args?: Input<Input<string>[]> }) {
1818
const redisService = getLocalComposeConfig().service('redis');
1919
const name = 'redis-store';
2020

@@ -64,6 +64,7 @@ export class Redis {
6464
{
6565
name,
6666
image: redisService.image,
67+
args,
6768
env,
6869
volumeMounts,
6970
ports: [{ containerPort: PORT, protocol: 'TCP' }],

0 commit comments

Comments
 (0)