Rust with Lambda, easy-mode Rust & future of Middy | ft. Luciano Mammino

Поділитися
Вставка
  • Опубліковано 18 лис 2024

КОМЕНТАРІ • 3

  • @s.vortex
    @s.vortex 3 місяці тому +3

    I recently switched from Node to Go and noticed huge improvements in cold start time. However, once I need to access other services, say DynamoDB, through SSL/TLS the few milliseconds saved from moving from Go to Rust seems negligible. The initial SSL/TLS handshake in my case take at least 500-600ms. Do you have any practical tips to speed up this handshake process in Lambda functions? Not like adding AWS secret keys to environment configuration. Thanks!

    • @s.vortex
      @s.vortex 3 місяці тому +1

      Of course I know I can increase the memory size. Is there other option?

    • @Loige
      @Loige 3 місяці тому +3

      A couple of ideas:
      1. use RustTLS (rather than OpenSSL) when possible (AFAIK it's enabled by default in the AWS SDK, but if you do HTTP requests to other services using a client like Reqwest you'll need to explicitly enable RusTLS)
      2. Make sure your clients are initialized in the `main` function and not in the handler. This way you'll establish the connection only once at cold start rather than for every single event being processed.
      I hope this helps, but let me know if you discover other optimizations