Limiting number of connections with enabling cache

Hi all!

Description: developing a web-server on STM32F4 MCU, trying to make a robust web-server able to work with most web browsers.

Problem: I noticed that once I am enabling cache (using #define MBEDTLS_SSL_CACHE_C) then I have web-server working quite fast, but in case if I try to open the web-server in many browsers (say in 3 browsers same time and each making constant periodical requests) - then I face a out of memory problem. However, in case if I disable cache - then there is no problem happening, but communication is done quite slow.

Question: is there is a way to limit number of simultaneous connections and to enable cache usage at this? I saw that there are 2 options for cache:

  • MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT
  • MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES
    Can they help it?

Thank you!

Hi @Evgeniy_Vasyliev
Yes, defining MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES or calling mbedtls_ssl_cache_set_max_entries() should limit you to the number of entries you can store in your cache. The timeout indicates the lifetime of a cache entry.
Regards,
Mbed TLS Team member
Ron