Redis - boostcamp-2020/Project03-A-TOTP GitHub Wiki

Session ์ •๋ณด๋ฅผ ์–ด๋””์— ์ €์žฅํ• ๊นŒ?

  • ๋ฉ”๋ชจ๋ฆฌ์—?
    • production ํ™˜๊ฒฝ์—์„œ๋Š” ์ ํ•ฉํ•˜์ง€ ์•Š๋‹ค๊ณ  ํ•œ๋‹ค express-session ์ฐธ๊ณ 
  • php๋Š” ํŒŒ์ผ๋กœ ์ €์žฅ
  • spring์€ redis ์‚ฌ์šฉ

NoSQL vs SQL Databases

NoSQL์ด ์ฝ๋Š” ์†๋„๊ฐ€ ๋” ๋น ๋ฅด๋‹ค๊ณ  ํ•œ๋‹ค

Redis vs Memcached vs MongoDB

https://db-engines.com/en/system/Redis%3BMemcached%3BMongoDB

ํ•ญ๋ชฉ Redis Memcached MongoDB
์„ค๋ช… In-memory ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ ์ €์žฅ์†Œ, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค, ์บ์‹œ, ๋ฉ”์‹œ์ง€ ๋ธŒ๋กœ์ปค์— ์‚ฌ์šฉ๋œ๋‹ค In-memory ํ‚ค-๋ฐธ๋ฅ˜ ์ €์žฅ์†Œ, ์บ์‹ฑ ์šฉ๋„๋กœ ์‚ฌ์šฉ๋œ๋‹ค ๊ฐ€์žฅ ๋„๋ฆฌ ์“ฐ์ด๋Š” ๋ฌธ์„œ ์ €์žฅ์†Œ(document stroe)
๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ชจ๋ธ Key-value store Key-value store Document store
๊ฐœ๋ฐœ ์—ฐ๋„ 2009 2003 2009
๋ฐ์ดํ„ฐ ํƒ€์ž… string, hash, list, set, sorted set, bit array, hyperloglog, geospatial index string string, integer, double, decimal, boolean, date, object_id, geospatial

Redis vs Memcached

  • ๋งด์บ์‰ฌ๋“œ๋Š” ๋ช…๋ฃŒํ•˜๊ณ  ๋‹จ์ˆœํ•จ์„ ์œ„ํ•˜์—ฌ ๊ฐœ๋ฐœ๋œ ๋ฐ˜๋ฉด, ๋ ˆ๋””์Šค๋Š” ๋‹ค์–‘ํ•œ ์šฉ๋„์— ํšจ๊ณผ์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๋งŽ์€ ํŠน์ง•์„ ๊ฐ€์ง€๊ณ  ๊ฐœ๋ฐœ๋˜์—ˆ์Šต๋‹ˆ๋‹ค
  • ๊ณตํ†ต์ 
    • ๋‘˜ ๋‹ค ๋ฐ์ดํ„ฐ๋ฅผ ๋ฉ”๋ชจ๋ฆฌ์— ์ €์žฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— 1ms ์ดํ•˜์˜ ๋น ๋ฅธ ์‘๋‹ต๋Œ€๊ธฐ์‹œ๊ฐ„์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค
  • Redis ๐Ÿ‘
    • Redis๊ฐ€ ๋” ๋‹ค์–‘ํ•œ ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค
    • Memcached๋Š” ๋ฉ”๋ชจ๋ฆฌ์—๋งŒ ์ €์žฅํ•ด์„œ ์žฅ์• ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ๋ฐ์ดํ„ฐ๊ฐ€ ์œ ์‹ค๋˜์ง€๋งŒ, Redis๋Š” ๋””์Šคํฌ์—๋„ ์ €์žฅํ•˜๋ฏ€๋กœ ๋ฐ์ดํ„ฐ ๋ณต๊ตฌ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค
    • ๋ฐ์ดํ„ฐ ์‚ญ์ œ ์ •์ฑ…์ด ๋‹ค์–‘ํ•˜๋‹ค. Memcached๋Š” LRU ์‚ญ์ œ ์ •์ฑ…๋งŒ ์ง€์›ํ•œ๋‹ค. ๋ฐ˜๋ฉด Redis๋Š” ์ข€๋” ๋‹ค์–‘ํ•˜๋‹ค
    • ํ•œ ๊ฐœ์˜ ํ‚ค์— ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” VALUE์˜ ๋ฒ”์œ„๊ฐ€ 521MB๋กœ, 1MB์ธ Memcached์— ๋น„ํ•ด ๋” ํฌ๋‹ค
  • Memcached ๐Ÿ‘
    • Memcahed๋Š” ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ๋ฅผ ์ง€์›ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฉ€ํ‹ฐ์ฝ”์–ดํ”„๋กœ์„ธ์„œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํ™˜๊ฒฝ์—์„œ ๋” ๋งŽ์€ ์ž‘์—…์ฒ˜๋ฆฌ๋ฅผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค
    • ๋ฉ”๋ชจ๋ฆฌ๋Š” Memcached๊ฐ€ ๋” ์ ๊ฒŒ ์š”๊ตฌํ•ฉ๋‹ˆ๋‹ค (Redis๋Š” ํ•„์š”ํ•œ ๋ฉ”๋ชจ๋ฆฌ์˜ 2๋ฐฐ๊ฐ€ ํ•„์š”ํ•จ)

๋Œ€๋ถ€๋ถ„์˜ ๊ฒฝ์šฐ์—์„œ๋Š” Redis๋ฅผ ์ถ”์ฒœํ•˜๋Š” ๊ฒƒ์œผ๋กœ ๋ณด์ž…๋‹ˆ๋‹ค

Redis vs MongoDB