Solutions I can think of:
- add a memory cache [ ticketId => redisKey ]
(it should help a lot, even if it will still be slower than before in case of load balancing)
- revert suffixing redis key with userid
(easy change in RedisTicketRegistry.java)
- and possibly add userid suffix in a UniqueTicketIdGenerator, the way HostNameBasedUniqueTicketIdGenerator suffixes with hostname
(but it may be hard to do...)
cu
On 28/10/2022 11:13, Jérôme LELEU wrote:
> Hi,
>
> Thanks for raising the point.
>
> It's always hard to find a good balance between a generic design and performance.
>
> It seems to me that performing scans to get a ticket is not the best thing to do in terms of performance.
>
> The Redis ticket registry is commonly used and we should try to avoid any performance degradation.
>
> I have a few ideas in mind, but I'm not a Redis specialist: what do you propose?
>
> Thanks.
> Best regards,
> Jérôme
>
>
> Le jeu. 27 oct. 2022 à 19:59, Pascal Rigaux <pascal...@univ-paris1.fr <mailto:pascal...@univ-paris1.fr>> a écrit :
>
> Hi,
>
> In 6.6.x Redis ticket registry key is suffixed with userid (since 6.6.0-RC4)
>
> This is great to know who owns a TGT or a ST.
>
> Alas, this means getting a TGT from Redis now requires a "SCAN"... which is much more costly.
> Example: full "SCAN" is ~100 times slower then "GET" on our production Redis (dbsize ~100k, because we have 1 month rememberMe TGT)
>
>
> For the record, getting a ST triggers
> - on 5.3 : 8 redis "GET" on the TGT
> - on 6.5 : 17 redis "GET" on the TGT
> - on 6.6 : 15 redis "SCAN" + "GET" on the TGT on a small redis db
>
>
>
> PS: "cas.ticket.registry.core.enable-locking=false" fails on redis ticket registry with error
> > Could not find a destroy method named 'destroy' on bean with name 'casTicketRegistryRedisLockRegistry'
--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/fcfa4754-17f7-384f-7254-e6faad0f4cff%40univ-paris1.fr.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-dev/CAGSBKkfEV2jEH%2BeRoWjnHPO71m1e4QFqRjL5H_iCJz2tyg7n5g%40mail.gmail.com.
private static AtomicLong getTime = new AtomicLong();
private static AtomicInteger nbGet = new AtomicInteger();
@Override
public Ticket getTicket(final String ticketId, final Predicate<Ticket> predicate) {
val t0 = System.currentTimeMillis();
try {
val redisKey = getTicketRedisKey(encodeTicketId(ticketId));
val t = this.client.boundValueOps(redisKey).get();
if (t != null) {
val result = decodeTicket(t);
if (predicate.test(result)) {
return result;
}
LOGGER.trace("The condition enforced by [{}] cannot successfully accept/test the ticket id [{}]", ticketId,
predicate.getClass().getSimpleName());
return null;
}
} catch (final Exception e) {
LOGGER.error("Failed fetching [{}]", ticketId);
LoggingUtils.error(LOGGER, e);
} finally {
val t1 = System.currentTimeMillis();
val time = t1 - t0;
val t = getTime.addAndGet(time);
val n = nbGet.incrementAndGet();
LOGGER.info("### GET time: {} ms | Average time: {} ms", time, t / n);
}
return null;
}
@Override
public Ticket getTicket(final String ticketId, final Predicate<Ticket> predicate) {
val t0 = System.currentTimeMillis();
try {
val redisKey = RedisCompositeKey.builder().id(encodeTicketId(ticketId)).build().toKeyPattern();
return getKeysStream(redisKey)
.map(key -> redisTemplate.boundValueOps(key).get())
.filter(Objects::nonNull)
.map(this::decodeTicket)
.filter(predicate)
.findFirst()
.orElse(null);
} catch (final Exception e) {
LOGGER.error("Failed fetching [{}]", ticketId);
LoggingUtils.error(LOGGER, e);
} finally {
val t1 = System.currentTimeMillis();
val time = t1 - t0;
val t = getTime.addAndGet(time);
val n = nbGet.incrementAndGet();
LOGGER.info("### GET time: {} ms | Average time: {} ms", time, t / n);
}
return null;
}
--
You received this message because you are subscribed to the Google Groups "CAS Developer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-dev+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-dev/CAGSBKkd9v9ss_BCoQwH6X%2B9OrtPWyuDjNaZJy3SusMMD578gGA%40mail.gmail.com.
Hi,
I have made new tests.With the new implementation, I have experienced Redis crashes, but I'm not sure this is meaningful.In any case, I have updated to Redis v7 with 500Mo of memory.
CAS v6.5 :
Average time node 1: 1 ms
Average time node 2: 1 ms
CAS v7.0.0 fix REDIS :
Average time node 1: 2 ms
Average time node 2: 2 msWhile it performs better on CAS v6.5, it now performs very well on CAS v7 as well.Did you change something else in addition to the cache?
--
You received this message because you are subscribed to the Google Groups "CAS Developer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-dev+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-dev/CAGSBKkfu1sjXEO1MPiq%3DjhhNhce%3DX6gy_LwASdvuMeRtUZ5hfQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-dev/CAGSBKkcJaC1QaBq%3DhcBqDWRYamUrfM_VGRrxerXompCKMAZNfA%40mail.gmail.com.