{"id":26509,"date":"2022-09-03T10:08:34","date_gmt":"2022-09-03T03:08:34","guid":{"rendered":"https:\/\/doc.bnix.vn\/?p=26509"},"modified":"2022-09-03T10:12:46","modified_gmt":"2022-09-03T03:12:46","slug":"redis-la-gi-vi-sao-no-duoc-cac-dev-san-don","status":"publish","type":"post","link":"https:\/\/doc.bnix.vn\/redis-la-gi-vi-sao-no-duoc-cac-dev-san-don\/","title":{"rendered":"Redis l\u00e0 g\u00ec? V\u00ec sao n\u00f3 \u0111\u01b0\u1ee3c c\u00e1c Dev s\u0103n \u0111\u00f3n?"},"content":{"rendered":"\n\n
\n \n
\n \n
\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n <\/div>\n \n
\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n <\/div>\n<\/div>\n \n\n
\n 4.3\/5 - (3 b\u00ecnh ch\u1ecdn) <\/div>\n <\/div>\n\n

Redis l\u00e0 g\u00ec?<\/h2>\n\n\n\n

Redis <\/strong>l\u00e0 t\u00ean vi\u1ebft t\u1eaft c\u1ee7a Remote Dictionary Server (M\u00e1y ch\u1ee7 t\u1eeb \u0111i\u1ec3n t\u1eeb xa), \u0111\u00e2y l\u00e0 m\u1ed9t kho l\u01b0u tr\u1eef d\u1eef li\u1ec7u d\u01b0\u1edbi d\u1ea1ng key-value, tr\u00ean b\u1ed9 nh\u1edb, m\u00e3 ngu\u1ed3n m\u1edf, nhanh ch\u00f3ng. D\u1ef1 \u00e1n n\u00e0y \u0111\u00e3 b\u1eaft \u0111\u1ea7u khi Salvatore Sanfilippo, nh\u00e0 ph\u00e1t tri\u1ec3n ban \u0111\u1ea7u c\u1ee7a Redis<\/strong>, mu\u1ed1n c\u1ea3i thi\u1ec7n kh\u1ea3 n\u0103ng m\u1edf r\u1ed9ng quy m\u00f4 c\u00f4ng ty kh\u1edfi nghi\u1ec7p c\u1ee7a \u00f4ng t\u1ea1i \u00dd. T\u1eeb \u0111\u00f3, \u00f4ng \u0111\u00e3 ph\u00e1t tri\u1ec3n Redis <\/strong>m\u00e0 hi\u1ec7n \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng v\u1edbi vai tr\u00f2 c\u01a1 s\u1edf d\u1eef li\u1ec7u, b\u1ed9 nh\u1edb \u0111\u1ec7m, tr\u00ecnh trung chuy\u1ec3n tin nh\u1eafn v\u00e0 h\u00e0ng \u0111\u1ee3i.<\/p>\n\n\n

\n
\"\"
H\u1ec7 th\u00f3ng Redis<\/figcaption><\/figure><\/div>\n\n\n

Redis <\/strong>l\u00e0 m\u1ed9t h\u1ec7 th\u1ed1ng d\u00f9ng \u0111\u1ec3 l\u01b0u tr\u1eef d\u1eef li\u1ec7u d\u01b0\u1edbi d\u1ea1ng Key \u2013 Value m\u1ea1nh m\u1ebd. N\u1ebfu n\u00f3i Redis <\/strong>nh\u01b0 m\u1ed9t b\u1ed9 nh\u1edb Cache, m\u1ed9t Database ho\u1eb7c Message Broker c\u0169ng kh\u00f4ng sai. M\u1ecdi th\u00f4ng tin, d\u1eef li\u1ec7u \u0111\u1ec1u \u0111\u01b0\u1ee3c redis <\/strong>ghi tr\u00ean ram thay v\u00ec \u1ed5 \u0111\u0129a hay \u1ed5 SSD nh\u01b0 b\u00ecnh th\u01b0\u1eddng. Nh\u1edd vi\u1ec7c kh\u00f4ng c\u1ea7n d\u00f9ng \u1ed5 \u0111\u0129a hay \u1ed5 SSD n\u00ean Redis <\/strong>s\u1ebd r\u00fat ng\u1eafn th\u1eddi gian t\u00ecm ki\u1ebfm, truy c\u1eadp d\u1eef li\u1ec7u. V\u00ec th\u1ebf m\u00e0 t\u1ed1c \u0111\u1ed9 \u0111\u1ecdc v\u00e0 ghi d\u1eef li\u1ec7u tr\u00ean Redis <\/strong>r\u1ea5t nhanh, r\u1ea5t l\u00fd t\u01b0\u1edfng.<\/p>\n\n\n\n

V\u00ec sao Redis \u0111\u01b0\u1ee3c c\u00e1c Developer s\u0103n \u0111\u00f3n?<\/h2>\n\n\n
\n
\"\"
Vai tr\u00f2 c\u1ee7a Redis<\/figcaption><\/figure><\/div>\n\n\n

\u01afu \u0111i\u1ec3m c\u1ee7a Redis l\u00e0 g\u00ec?<\/h2>\n\n\n\n

\u01afu \u0111i\u1ec3m thu h\u00fat c\u00e1c l\u1eadp tr\u00ecnh vi\u00ean s\u0103n \u0111\u00f3n Redis <\/strong>l\u00e0 g\u00ec? \u1ee8ng d\u1ee5ng redis<\/strong>, ng\u01b0\u1eddi d\u00f9ng s\u1ebd \u0111\u01b0\u1ee3c \u201ct\u1eadn h\u01b0\u1edfng\u201d nhi\u1ec1u \u0111i\u1ec3m c\u1ed9ng kh\u00f4ng th\u1ec3 n\u00e0o l\u00fd t\u01b0\u1edfng h\u01a1n:<\/p>\n\n\n\n

  • Redis <\/strong>h\u1ed7 tr\u1ee3 ng\u01b0\u1eddi d\u00f9ng c\u00f3 th\u1ec3 th\u00eam m\u1edbi ho\u1eb7c lo\u1ea1i b\u1ecf d\u1eef li\u1ec7u trong th\u1eddi gian ng\u1eafn.<\/li>
  • Redis <\/strong>c\u00f3 th\u1ec3 nh\u1eadn v\u00e0 ghi d\u1eef li\u1ec7u l\u00ean Ram v\u00e0 c\u00f3 th\u1ec3 xu\u1ea5t hi\u1ec7n tr\u00ean Disk t\u1ea1i m\u1ed9t th\u1eddi \u0111i\u1ec3m.<\/li>
  • Key c\u1ee7a Redis <\/strong>l\u00e0 m\u1ed9t string nh\u01b0ng \u0111\u01b0\u1ee3c h\u1ed7 tr\u1ee3 s\u1eed d\u1ee5ng linh ho\u1ea1t \u0111a d\u1ea1ng c\u00e1c value nh\u01b0 List, Sorted sets, Sets,\u2026<\/li>
  • D\u1ec5 d\u00e0ng di chuy\u1ec3n key t\u1eeb c\u01a1 s\u1edf d\u1eef li\u1ec7u n\u00e0y sang c\u01a1 s\u1edf d\u1eef li\u1ec7u kh\u00e1c.<\/li>
  • Redis \u0111\u01b0\u1ee3c trang b\u1ecb nhi\u1ec1u l\u1ec7nh \u0111\u1eb7c bi\u1ec7t. V\u00ec th\u1ebf m\u00e0 Redis <\/strong>r\u1ea5t nhanh trong qu\u00e1 tr\u00ecnh l\u1ea5y v\u00e0 ghi d\u1eef li\u1ec7u.<\/li>
  • T\u00ednh n\u0103ng Master \u2013 slave th\u00edch h\u1ee3p cho ng\u01b0\u1eddi d\u00f9ng mu\u1ed1n gia t\u0103ng s\u1ef1 an to\u00e0n cho d\u1eef li\u1ec7u, m\u1edf r\u1ed9ng ho\u1eb7c thu h\u1eb9p kh\u00f4ng gian l\u01b0u tr\u1eef Data.<\/li>
  • Ng\u01b0\u1eddi d\u00f9ng c\u00f3 th\u1ec3 t\u00ecm ki\u1ebfm d\u1eef li\u1ec7u nhanh ch\u00f3ng nh\u1ea5t.<\/li>
  • Redis <\/strong>cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng s\u1eed d\u1ee5ng linh ho\u1ea1t nhi\u1ec1u ki\u1ec3u d\u1eef li\u1ec7u kh\u00e1c nhau.<\/li>
  • Ng\u01b0\u1eddi d\u00f9ng c\u00f3 th\u1ec3 \u0111\u1ec3 key t\u1ef1 \u0111\u1ed9ng x\u00f3a \u0111i \u1edf m\u1ed9t th\u1eddi gian nh\u1ea5t \u0111\u1ecbnh n\u00e0o \u0111\u00f3.<\/li><\/ul>\n\n\n\n

    Nhi\u1ec1u \u01b0u \u0111i\u1ec3m l\u00e0 th\u1ebf, nh\u01b0ng kh\u00f4ng ph\u1ea3i Redis <\/strong>l\u00e0 m\u1ed9t h\u1ec7 th\u1ed1ng l\u01b0u tr\u1eef d\u1eef li\u1ec7u ho\u00e0n h\u1ea3o.<\/p>\n\n\n\n

    Nh\u01b0\u1ee3c \u0111i\u1ec3m c\u1ee7a Redis l\u00e0 g\u00ec?<\/strong><\/h2>\n\n\n\n
    • RDB kh\u00f4ng ph\u1ea3i l\u00e0 l\u1ef1a ch\u1ecdn t\u1ed1t n\u1ebfu b\u1ea1n mu\u1ed1n gi\u1ea3m thi\u1ec3u t\u1ed1i \u0111a nguy c\u01a1 m\u1ea5t m\u00e1t d\u1eef li\u1ec7u.<\/li>
    • Th\u00f4ng th\u01b0\u1eddng ng\u01b0\u1eddi d\u00f9ng s\u1ebd set up \u0111\u1ec3 t\u1ea1o RDB snapshot 5 ph\u00fat 1 l\u1ea7n (ho\u1eb7c nhi\u1ec1u h\u01a1n). Do v\u1eady, trong tr\u01b0\u1eddng h\u1ee3p c\u00f3 s\u1ef1 c\u1ed1, Redis <\/strong>kh\u00f4ng th\u1ec3 ho\u1ea1t \u0111\u1ed9ng, d\u1eef li\u1ec7u trong nh\u1eefng ph\u00fat cu\u1ed1i s\u1ebd b\u1ecb m\u1ea5t.<\/li>
    • RDB c\u1ea7n d\u00f9ng fork() \u0111\u1ec3 t\u1ea1o ti\u1ebfn tr\u00ecnh con ph\u1ee5c v\u1ee5 cho thao t\u00e1c disk I\/O. Trong tr\u01b0\u1eddng h\u1ee3p d\u1eef li\u1ec7u qu\u00e1 l\u1edbn, qu\u00e1 tr\u00ecnh fork() c\u00f3 th\u1ec3 t\u1ed1n th\u1eddi gian v\u00e0 server s\u1ebd kh\u00f4ng th\u1ec3 \u0111\u00e1p \u1ee9ng \u0111\u01b0\u1ee3c request t\u1eeb client trong v\u00e0i milisecond ho\u1eb7c th\u1eadm ch\u00ed l\u00e0 1 second t\u00f9y thu\u1ed9c v\u00e0o l\u01b0\u1ee3ng data v\u00e0 hi\u1ec7u n\u0103ng CPU.<\/li><\/ul>\n\n\n\n

      K\u1ebft lu\u1eadn<\/h2>\n\n\n\n

      Redis<\/strong> l\u00e0 m\u1ed9t s\u1ef1 l\u1ef1a ch\u1ecdn tuy\u1ec7t v\u1eddi khi ta c\u1ea7n \u0111\u1ebfn m\u1ed9t server l\u01b0u tr\u1eef d\u1eef li\u1ec7u \u0111\u00f2i h\u1ecfi t\u00ednh m\u1edf r\u1ed9ng cao (scaleable) v\u00e0 chia s\u1ebb b\u1edfi nhi\u1ec1u ti\u1ebfn tr\u00ecnh, nhi\u1ec1u \u1ee9ng d\u1ee5ng v\u00e0 nhi\u1ec1u server kh\u00e1c nhau.<\/p>\n\n\n\n

      <\/p>\n","protected":false},"excerpt":{"rendered":"

      Redis l\u00e0 g\u00ec? Redis l\u00e0 t\u00ean vi\u1ebft t\u1eaft c\u1ee7a Remote Dictionary Server (M\u00e1y ch\u1ee7 t\u1eeb \u0111i\u1ec3n…<\/p>\n","protected":false},"author":3,"featured_media":26514,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[224],"tags":[],"class_list":["post-26509","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"_links":{"self":[{"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/posts\/26509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/comments?post=26509"}],"version-history":[{"count":0,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/posts\/26509\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/media\/26514"}],"wp:attachment":[{"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/media?parent=26509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/categories?post=26509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/tags?post=26509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}