Springboot-Version 3.4.5
Lettuce-Version 6.8.1.RELEASE
Elasticache Valkey serverlos mit IAM-Authentifizierung
Während des Lasttests wurde seltsames Verhalten beobachtet. Wenn die automatische Skalierung von ECS-Aufgaben bei hoher Auslastung (CPU > 50 %) bei 500 U/s beginnt,
- API-Latenzspitzen
- API-Aufrufe-Timeout mit 504
- Elasticache-Befehle schlagen mit Verbindungs-Timeout und Befehls-Timeout fehl
- Die Integritätsprüfung von ECS-Aufgaben schlägt fehl und Aufgaben werden für eine Dauer in einer Schleife erstellt/beendet while
Die Richtlinie für die automatische Skalierung wird ausgelöst, wenn:
CPU-Auslastung >50 %
Speicherauslastung >50 %
Elasticache-Konfiguration:
maxTotal 15
maxIdle 8
minIdle 3
Verbindungs-Timeout 3s
Befehls-Timeout 2s
Was läuft hier falsch?
Unten ist die Elasticache-Konfigurationsklasse. Vielen Dank im Voraus.
Code: Select all
public class ElastiCacheConfig {
@Bean(destroyMethod = "shutdown")
public ClientResources clientResources() {
return DefaultClientResources.builder()
.ioThreadPoolSize(8)
.computationThreadPoolSize(8)
.reconnectDelay(Delay.equalJitter(
Duration.ofMillis(100),
Duration.ofSeconds(30),
1, TimeUnit.MILLISECONDS))
.build();
}
@Bean(destroyMethod = "shutdown")
public RedisClient redisClient(ClientResources clientResources) {
RedisURI redisURI = RedisURI.builder()
.withHost(host)
.withPort(6379)
.withSsl(true)
.withAuthentication(getCredentials())
.withTimeout(Duration.ofMillis(3000))
.build();
RedisClient client = RedisClient.create(clientResources, redisURI);
client.setOptions(createClientOptions());
return client;
}
@Bean
public CompletionStage cacheAsyncConnectionPool(RedisClient redisClient) {
RedisURI redisURI = RedisURI.builder()
.withHost(host)
.withPort(port)
.withSsl(true)
.withAuthentication(getCredentials())
.withTimeout(Duration.ofMillis(3000))
.build();
BoundedPoolConfig poolConfig = BoundedPoolConfig.builder()
.maxTotal(15)
.maxIdle(8)
.minIdle(3)
.testOnAcquire(true)
.testOnCreate(true)
.build();
return AsyncConnectionPoolSupport.createBoundedObjectPoolAsync(
() -> redisClient.connectAsync(StringCodec.UTF8, redisURI),
poolConfig);
}
private ClientOptions createClientOptions() {
return ClientOptions.builder()
.pingBeforeActivateConnection(true)
.socketOptions(SocketOptions.builder()
.connectTimeout(Duration.ofMillis(3000))
.keepAlive(true)
.tcpNoDelay(true)
.build())
.timeoutOptions(TimeoutOptions.builder()
.fixedTimeout(Duration.ofMillis(2000))
.build())
.build();
}
private RedisCredentialsProvider getCredentials() {
AWSCredentialsProvider awsCredentialsProvider = new DefaultAWSCredentialsProviderChain();
IAMAuthTokenRequest iamAuthTokenRequest = new IAMAuthTokenRequest(user, name, region, true);
return new RedisIAMAuthCredentialsProvider(
user, iamAuthTokenRequest, awsCredentialsProvider);
}
Mobile version