Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Go and Redis, Better Together

Go and Redis, Better Together

Abhishek Gupta

April 24, 2023
Tweet

More Decks by Abhishek Gupta

Other Decks in Programming

Transcript

  1. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Go and Redis, Better Together Abhishek Gupta Principal Developer Advocate Amazon Web Services @abhi_tweter
  2. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. abhirockzz.github.io @abhi_tweter abhirockzz abhirockzz 👋
  3. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter Go and Redis – Intro Go and Redis in action - Common use cases Things you should know – tips, tricks, good practices… Agenda (Keep It Simple)
  4. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter I ❤ Redis
  5. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter Redis: One of THE most ❤ databases out there! DB Engines ranking Stack Overflow survey 2021
  6. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter I ❤
  7. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Go - Cloud native lingua franca From go.dev Stack Overflow survey 2022
  8. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Simplicity Redis Commands (data types)
  9. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Simplicity Video and slides
  10. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Redis 101
  11. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter Redis: Open Source Key-Value store Not just a cache Streaming, Pub/Sub, Queuing High Availability Redis Cluster: Replication and horizontal scalability Persistent In-memory for fast access, but can also persist writes In-Memory Data Structures Strings, Hashes, Lists, Sets…. Run Anywhere Cloud, Kubernetes, On-prem
  12. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter Flexible: Redis data structures and APIs Data type Description Associated commands String Sequence of bytes APPEND,GET,SET,INCR,DECR,GETSET... List A list of strings LSET,LLEN,LPUSH,LPOP,LTRIM,RPOP... Set Nonrepeating, unordered collection of strings SADD,SCARD,SDIFF,SUNION,SINTER,SMEMBERS... Sorted set Nonrepeating, ordered collection of strings ZADD,ZCARD,ZCOUNT,ZRANK,ZSCORE... Hash Map of key-value pairs HGET,HGETALL,HKEYS,HVALS,HMSET,HMGET... Streams Log data structure XADD,XRANGE,XREAD,XACK,XCLAIM,XLEN... Geospatial Longitude-/latitude-based entries GEOADD,GEODIST,GEOPOS,GEORADIUS... Bitmaps Special usage of string type GETBIT,BITCOUNT,SETBIT,SETRANGE,GETRANGE... HyperLogLogs Probabilistic data structure PFADD,PFCOUNT,PFMERGE
  13. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Clients for Redis
  14. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Popular ones… List of Redis Clients
  15. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter go-redis - github.com/redis/go-redis redis.com announcement uptrace.dev announcement redis.uptrace.dev
  16. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter redigo - github.com/gomodule/redigo - Stable - Used in other implementations - API – too generic (?) - No Redis Cluster support 😲
  17. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter rueidis - github.com/rueian/rueidis - (Relatively) New - Lots of features! - Interesting API - Benchmark comparison
  18. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Redis Client Ecosystem 1 2 3 4 5
  19. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Time for 🧑💻
  20. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Tips, tricks and more…
  21. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter First things first…
  22. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Use the appropriate connection mode
  23. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Unable to connect to Redis, help! 😢 It’s probably the networking/security configuration Amazon ElastiCache and VPC
  24. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Redis scalability, Redis Cluster
  25. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter Scaling Redis: Optimize for reads, write, or both? Amazon Elasticache documentation
  26. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter After scaling your cluster, you better use those replicas! READONLY mode
  27. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Redis cluster: Use Hash Tags to influence how your keys are distributed Note the difference?
  28. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Sharded Pub/Sub Documentation
  29. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Bulk operations (cross-cluster)
  30. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Resources
  31. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter Learn more... Go Redis GitHub repo Discord channel – Interact with the community Documentation Redis docs – great (general) resource Go Redis client – brief, but useful Using Redis on AWS? Op#mize Redis Client Performance for Amazon Elas#Cache and MemoryDB Best prac#ces: Redis clients and Amazon Elas#Cache for Redis Measuring database performance of Amazon MemoryDB for Redis
  32. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. @abhi_tweter Other content….. Using Redis on Cloud? Manage Redis on AWS from Kubernetes Leaderboard app Getting started
  33. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. @abhi_tweter Thank you! © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Abhishek Gupta Principal Developer Advocate Amazon Web Services @abhi_tweter https://pulse.buildon.aws/survey/ATNUMPOQ