Skip to content

Tweaker rolling updates ved deploy #1716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .nais/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ spec:
env:
- name: NPM_CONFIG_CACHE
value: /tmp/npm-cache
strategy:
rollingUpdate:
maxSurge: 3
replicas:
{{#with replicas}}
min: {{min}}
Expand All @@ -63,4 +66,4 @@ spec:
memory: {{requests.memory}}
limits:
memory: {{limits.memory}}
{{/with}}
{{/with}}
10 changes: 9 additions & 1 deletion .nais/hpa/hpa-dev1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ spec:
name: nav-enonicxp-frontend-dev1
minReplicas: 2
maxReplicas: 4
behavior:
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Pods
value: 2
periodSeconds: 60
selectPolicy: Max
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 60
averageUtilization: 75
- type: Pods
pods:
metric:
Expand Down
9 changes: 1 addition & 8 deletions .nais/hpa/hpa-dev2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,4 @@ spec:
name: cpu
target:
type: Utilization
averageUtilization: 60
- type: Pods
pods:
metric:
name: http_request_duration_seconds_count
target:
type: AverageValue
averageValue: '250'
averageUtilization: 75
8 changes: 8 additions & 0 deletions .nais/hpa/hpa-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ spec:
name: nav-enonicxp-frontend
minReplicas: 2
maxReplicas: 40
behavior:
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Pods
value: 2
periodSeconds: 60
selectPolicy: Max
metrics:
- type: Resource
resource:
Expand Down
2 changes: 1 addition & 1 deletion .nais/vars/vars-dev1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ resources:
cpu: 500m
memory: 1000Mi
limits:
memory: 1000Mi
memory: 2000Mi
replicas:
min: 2
max: 2
Expand Down
2 changes: 1 addition & 1 deletion .nais/vars/vars-dev2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ resources:
cpu: 250m
memory: 500Mi
limits:
memory: 500Mi
memory: 1000Mi
replicas:
min: 1
max: 2
Expand Down
19 changes: 2 additions & 17 deletions server/src/cache/page-cache-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ import FileSystemCache from 'next/dist/server/lib/incremental-cache/file-system-
import { LRUCache } from 'lru-cache';
import { CacheHandlerValue } from 'next/dist/server/lib/incremental-cache';
import { RedisCache } from 'srcCommon/redis';
import { CACHE_TTL_72_HOURS_IN_MS } from 'srcCommon/constants';
import { pathToCacheKey } from 'srcCommon/cache-key';

const TTL_RESOLUTION_MS = 60 * 1000;

export const redisCache = new RedisCache();

const localCache = new LRUCache<string, CacheHandlerValue>({
max: 4000,
ttl: CACHE_TTL_72_HOURS_IN_MS,
ttlResolution: TTL_RESOLUTION_MS,
max: 5000,
});

export default class PageCacheHandler {
Expand All @@ -29,17 +24,7 @@ export default class PageCacheHandler {
return null;
}

const ttlRemaining = fromRedisCache.lastModified
? fromRedisCache.lastModified +
CACHE_TTL_72_HOURS_IN_MS -
Date.now()
: CACHE_TTL_72_HOURS_IN_MS;

if (ttlRemaining > TTL_RESOLUTION_MS) {
localCache.set(key, fromRedisCache, {
ttl: ttlRemaining,
});
}
localCache.set(key, fromRedisCache);

return fromRedisCache;
}
Expand Down