blob: a7394b77df026f2522cb9d74f1b01dcfa88ff8c6 [file] [log] [blame]
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[5400],{28453:(e,n,d)=>{d.d(n,{R:()=>t,x:()=>c});var i=d(96540);const s={},r=i.createContext(s);function t(e){const n=i.useContext(r);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:t(e.components),i.createElement(r.Provider,{value:n},e.children)}},52113:(e,n,d)=>{d.r(n),d.d(n,{assets:()=>l,contentTitle:()=>c,default:()=>a,frontMatter:()=>t,metadata:()=>i,toc:()=>o});const i=JSON.parse('{"id":"development/extensions-contrib/redis-cache","title":"Druid Redis Cache","description":"\x3c!--","source":"@site/docs/latest/development/extensions-contrib/redis-cache.md","sourceDirName":"development/extensions-contrib","slug":"/development/extensions-contrib/redis-cache","permalink":"/docs/latest/development/extensions-contrib/redis-cache","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{"id":"redis-cache","title":"Druid Redis Cache"}}');var s=d(74848),r=d(28453);const t={id:"redis-cache",title:"Druid Redis Cache"},c=void 0,l={},o=[{value:"Installation",id:"installation",level:2},{value:"Enabling",id:"enabling",level:2},{value:"Configuration",id:"configuration",level:2},{value:"Cluster mode",id:"cluster-mode",level:3},{value:"Example",id:"example",level:4},{value:"Standalone mode",id:"standalone-mode",level:3},{value:"Shared Properties",id:"shared-properties",level:3},{value:"Metrics",id:"metrics",level:2}];function h(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.p,{children:["A cache implementation for Druid based on ",(0,s.jsx)(n.a,{href:"https://github.com/redis/redis",children:"Redis"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Below are guidance and configuration options known to this module."}),"\n",(0,s.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,s.jsxs)(n.p,{children:["Use ",(0,s.jsx)(n.a,{href:"/docs/latest/operations/pull-deps",children:"pull-deps"})," tool shipped with Druid to install this ",(0,s.jsx)(n.a,{href:"/docs/latest/configuration/extensions#community-extensions",children:"extension"})," on broker, historical and middle manager nodes."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:'java -classpath "druid_dir/lib/*" org.apache.druid.cli.Main tools pull-deps -c org.apache.druid.extensions.contrib:druid-redis-cache:{VERSION}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"enabling",children:"Enabling"}),"\n",(0,s.jsx)(n.p,{children:"To enable this extension after installation,"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"/docs/latest/configuration/extensions#loading-extensions",children:"include"})," this ",(0,s.jsx)(n.code,{children:"druid-redis-cache"})," extension"]}),"\n",(0,s.jsxs)(n.li,{children:["to enable cache on broker nodes, follow ",(0,s.jsx)(n.a,{href:"/docs/latest/configuration/#broker-caching",children:"broker caching docs"})," to set related properties"]}),"\n",(0,s.jsxs)(n.li,{children:["to enable cache on historical nodes, follow ",(0,s.jsx)(n.a,{href:"/docs/latest/configuration/#historical-caching",children:"historical caching docs"})," to set related properties"]}),"\n",(0,s.jsxs)(n.li,{children:["to enable cache on middle manager nodes, follow ",(0,s.jsx)(n.a,{href:"/docs/latest/configuration/#peon-caching",children:"peon caching docs"})," to set related properties"]}),"\n",(0,s.jsxs)(n.li,{children:["set ",(0,s.jsx)(n.code,{children:"druid.cache.type"})," to ",(0,s.jsx)(n.code,{children:"redis"})]}),"\n",(0,s.jsx)(n.li,{children:"add the following properties"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"configuration",children:"Configuration"}),"\n",(0,s.jsx)(n.h3,{id:"cluster-mode",children:"Cluster mode"}),"\n",(0,s.jsx)(n.p,{children:"To utilize a redis cluster, following properties must be set."}),"\n",(0,s.jsxs)(n.p,{children:["Note: some redis cloud service providers provide redis cluster service via a redis proxy, for these clusters, please follow the ",(0,s.jsx)(n.a,{href:"#standalone-mode",children:"Standalone mode"})," configuration below."]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Properties"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Required"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"druid.cache.cluster.nodes"})}),(0,s.jsx)(n.td,{children:"Redis nodes in a cluster, represented in comma separated string. See example below"}),(0,s.jsx)(n.td,{children:"None"}),(0,s.jsx)(n.td,{children:"yes"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"druid.cache.cluster.maxRedirection"})}),(0,s.jsx)(n.td,{children:"Max retry count"}),(0,s.jsx)(n.td,{children:"5"}),(0,s.jsx)(n.td,{children:"no"})]})]})]}),"\n",(0,s.jsx)(n.h4,{id:"example",children:"Example"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-properties",children:"# a typical redis cluster with 6 nodes\ndruid.cache.cluster.nodes=127.0.0.1:7001,127.0.0.1:7002,127.0.0.1:7003,127.0.0.1:7004,127.0.0.1:7005,127.0.0.1:7006\n"})}),"\n",(0,s.jsx)(n.h3,{id:"standalone-mode",children:"Standalone mode"}),"\n",(0,s.jsx)(n.p,{children:"To use a standalone redis, following properties must be set."}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Properties"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Required"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"druid.cache.host"})}),(0,s.jsx)(n.td,{children:"Redis server host"}),(0,s.jsx)(n.td,{children:"None"}),(0,s.jsx)(n.td,{children:"yes"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"druid.cache.port"})}),(0,s.jsx)(n.td,{children:"Redis server port"}),(0,s.jsx)(n.td,{children:"None"}),(0,s.jsx)(n.td,{children:"yes"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"druid.cache.database"})}),(0,s.jsx)(n.td,{children:"Redis database index"}),(0,s.jsx)(n.td,{children:"0"}),(0,s.jsx)(n.td,{children:"no"})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["Note: if both ",(0,s.jsx)(n.code,{children:"druid.cache.cluster.nodes"})," and ",(0,s.jsx)(n.code,{children:"druid.cache.host"})," are provided, cluster mode is preferred."]}),"\n",(0,s.jsx)(n.h3,{id:"shared-properties",children:"Shared Properties"}),"\n",(0,s.jsx)(n.p,{children:"Except for the properties above, there are some extra properties which can be customized to meet different needs."}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Properties"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Required"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"druid.cache.password"})}),(0,s.jsx)(n.td,{children:"Password to access redis server/cluster"}),(0,s.jsx)(n.td,{children:"None"}),(0,s.jsx)(n.td,{children:"no"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"druid.cache.expiration"})}),(0,s.jsx)(n.td,{children:"Expiration for cache entries"}),(0,s.jsx)(n.td,{children:"P1D"}),(0,s.jsx)(n.td,{children:"no"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"druid.cache.timeout"})}),(0,s.jsx)(n.td,{children:"Timeout for connecting to Redis and reading entries from Redis"}),(0,s.jsx)(n.td,{children:"PT2S"}),(0,s.jsx)(n.td,{children:"no"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"druid.cache.maxTotalConnections"})}),(0,s.jsx)(n.td,{children:"Max total connections to Redis"}),(0,s.jsx)(n.td,{children:"8"}),(0,s.jsx)(n.td,{children:"no"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"druid.cache.maxIdleConnections"})}),(0,s.jsx)(n.td,{children:"Max idle connections to Redis"}),(0,s.jsx)(n.td,{children:"8"}),(0,s.jsx)(n.td,{children:"no"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"druid.cache.minIdleConnections"})}),(0,s.jsx)(n.td,{children:"Min idle connections to Redis"}),(0,s.jsx)(n.td,{children:"0"}),(0,s.jsx)(n.td,{children:"no"})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["For ",(0,s.jsx)(n.code,{children:"druid.cache.expiration"})," and ",(0,s.jsx)(n.code,{children:"druid.cache.timeout"})," properties, values can be format of ",(0,s.jsx)(n.code,{children:"Period"})," or a number in milliseconds."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-properties",children:"# Period format(recomended)\n# cache expires after 1 hour\ndruid.cache.expiration=PT1H\n\n# or in number(milliseconds) format\n# 1 hour = 3_600_000 milliseconds\ndruid.cache.expiration=3600000\n"})}),"\n",(0,s.jsx)(n.h2,{id:"metrics",children:"Metrics"}),"\n",(0,s.jsxs)(n.p,{children:["In addition to the normal cache metrics, the redis cache implementation also reports the following in both ",(0,s.jsx)(n.code,{children:"total"})," and ",(0,s.jsx)(n.code,{children:"delta"})]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Metric"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{children:"Normal value"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"query/cache/redis/*/requests"})}),(0,s.jsx)(n.td,{children:"Count of requests to redis cache"}),(0,s.jsx)(n.td,{children:"whatever request to redis will increase request count by 1"})]})})]})]})}function a(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]);