blob: 7bf7fd21d866c56b8295e9867286ef8b165dd50c [file] [log] [blame]
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[7293],{15680:(e,t,n)=>{n.d(t,{xA:()=>g,yg:()=>m});var a=n(96540);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},l=Object.keys(e);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var d=a.createContext({}),p=function(e){var t=a.useContext(d),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},g=function(e){var t=p(e.components);return a.createElement(d.Provider,{value:t},e.children)},s="mdxType",c={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,d=e.parentName,g=o(e,["components","mdxType","originalType","parentName"]),s=p(n),u=r,m=s["".concat(d,".").concat(u)]||s[u]||c[u]||l;return n?a.createElement(m,i(i({ref:t},g),{},{components:n})):a.createElement(m,i({ref:t},g))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,i=new Array(l);i[0]=u;var o={};for(var d in t)hasOwnProperty.call(t,d)&&(o[d]=t[d]);o.originalType=e,o[s]="string"==typeof e?e:r,i[1]=o;for(var p=2;p<l;p++)i[p]=n[p];return a.createElement.apply(null,i)}return a.createElement.apply(null,n)}u.displayName="MDXCreateElement"},84367:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>g,contentTitle:()=>d,default:()=>m,frontMatter:()=>o,metadata:()=>p,toc:()=>s});var a=n(58168),r=n(98587),l=(n(96540),n(15680)),i=["components"],o={id:"redis-cache",title:"Druid Redis Cache"},d=void 0,p={unversionedId:"development/extensions-contrib/redis-cache",id:"development/extensions-contrib/redis-cache",title:"Druid Redis Cache",description:"\x3c!--",source:"@site/docs/29.0.0/development/extensions-contrib/redis-cache.md",sourceDirName:"development/extensions-contrib",slug:"/development/extensions-contrib/redis-cache",permalink:"/docs/29.0.0/development/extensions-contrib/redis-cache",draft:!1,tags:[],version:"current",frontMatter:{id:"redis-cache",title:"Druid Redis Cache"}},g={},s=[{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}],c={toc:s},u="wrapper";function m(e){var t=e.components,n=(0,r.A)(e,i);return(0,l.yg)(u,(0,a.A)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,l.yg)("p",null,"A cache implementation for Druid based on ",(0,l.yg)("a",{parentName:"p",href:"https://github.com/redis/redis"},"Redis"),"."),(0,l.yg)("p",null,"Below are guidance and configuration options known to this module."),(0,l.yg)("h2",{id:"installation"},"Installation"),(0,l.yg)("p",null,"Use ",(0,l.yg)("a",{parentName:"p",href:"/docs/29.0.0/operations/pull-deps"},"pull-deps")," tool shipped with Druid to install this ",(0,l.yg)("a",{parentName:"p",href:"/docs/29.0.0/configuration/extensions#community-extensions"},"extension")," on broker, historical and middle manager nodes."),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-bash"},'java -classpath "druid_dir/lib/*" org.apache.druid.cli.Main tools pull-deps -c org.apache.druid.extensions.contrib:druid-redis-cache:{VERSION}\n')),(0,l.yg)("h2",{id:"enabling"},"Enabling"),(0,l.yg)("p",null,"To enable this extension after installation,"),(0,l.yg)("ol",null,(0,l.yg)("li",{parentName:"ol"},(0,l.yg)("a",{parentName:"li",href:"/docs/29.0.0/configuration/extensions#loading-extensions"},"include")," this ",(0,l.yg)("inlineCode",{parentName:"li"},"druid-redis-cache")," extension"),(0,l.yg)("li",{parentName:"ol"},"to enable cache on broker nodes, follow ",(0,l.yg)("a",{parentName:"li",href:"/docs/29.0.0/configuration/#broker-caching"},"broker caching docs")," to set related properties"),(0,l.yg)("li",{parentName:"ol"},"to enable cache on historical nodes, follow ",(0,l.yg)("a",{parentName:"li",href:"/docs/29.0.0/configuration/#historical-caching"},"historical caching docs")," to set related properties"),(0,l.yg)("li",{parentName:"ol"},"to enable cache on middle manager nodes, follow ",(0,l.yg)("a",{parentName:"li",href:"/docs/29.0.0/configuration/#peon-caching"},"peon caching docs")," to set related properties"),(0,l.yg)("li",{parentName:"ol"},"set ",(0,l.yg)("inlineCode",{parentName:"li"},"druid.cache.type")," to ",(0,l.yg)("inlineCode",{parentName:"li"},"redis")),(0,l.yg)("li",{parentName:"ol"},"add the following properties")),(0,l.yg)("h2",{id:"configuration"},"Configuration"),(0,l.yg)("h3",{id:"cluster-mode"},"Cluster mode"),(0,l.yg)("p",null,"To utilize a redis cluster, following properties must be set."),(0,l.yg)("p",null,"Note: some redis cloud service providers provide redis cluster service via a redis proxy, for these clusters, please follow the ",(0,l.yg)("a",{parentName:"p",href:"#standalone-mode"},"Standalone mode")," configuration below."),(0,l.yg)("table",null,(0,l.yg)("thead",{parentName:"table"},(0,l.yg)("tr",{parentName:"thead"},(0,l.yg)("th",{parentName:"tr",align:null},"Properties"),(0,l.yg)("th",{parentName:"tr",align:null},"Description"),(0,l.yg)("th",{parentName:"tr",align:null},"Default"),(0,l.yg)("th",{parentName:"tr",align:null},"Required"))),(0,l.yg)("tbody",{parentName:"table"},(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"druid.cache.cluster.nodes")),(0,l.yg)("td",{parentName:"tr",align:null},"Redis nodes in a cluster, represented in comma separated string. See example below"),(0,l.yg)("td",{parentName:"tr",align:null},"None"),(0,l.yg)("td",{parentName:"tr",align:null},"yes")),(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"druid.cache.cluster.maxRedirection")),(0,l.yg)("td",{parentName:"tr",align:null},"Max retry count"),(0,l.yg)("td",{parentName:"tr",align:null},"5"),(0,l.yg)("td",{parentName:"tr",align:null},"no")))),(0,l.yg)("h4",{id:"example"},"Example"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-properties"},"# 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")),(0,l.yg)("h3",{id:"standalone-mode"},"Standalone mode"),(0,l.yg)("p",null,"To use a standalone redis, following properties must be set."),(0,l.yg)("table",null,(0,l.yg)("thead",{parentName:"table"},(0,l.yg)("tr",{parentName:"thead"},(0,l.yg)("th",{parentName:"tr",align:null},"Properties"),(0,l.yg)("th",{parentName:"tr",align:null},"Description"),(0,l.yg)("th",{parentName:"tr",align:null},"Default"),(0,l.yg)("th",{parentName:"tr",align:null},"Required"))),(0,l.yg)("tbody",{parentName:"table"},(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"druid.cache.host")),(0,l.yg)("td",{parentName:"tr",align:null},"Redis server host"),(0,l.yg)("td",{parentName:"tr",align:null},"None"),(0,l.yg)("td",{parentName:"tr",align:null},"yes")),(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"druid.cache.port")),(0,l.yg)("td",{parentName:"tr",align:null},"Redis server port"),(0,l.yg)("td",{parentName:"tr",align:null},"None"),(0,l.yg)("td",{parentName:"tr",align:null},"yes")),(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"druid.cache.database")),(0,l.yg)("td",{parentName:"tr",align:null},"Redis database index"),(0,l.yg)("td",{parentName:"tr",align:null},"0"),(0,l.yg)("td",{parentName:"tr",align:null},"no")))),(0,l.yg)("p",null,"Note: if both ",(0,l.yg)("inlineCode",{parentName:"p"},"druid.cache.cluster.nodes")," and ",(0,l.yg)("inlineCode",{parentName:"p"},"druid.cache.host")," are provided, cluster mode is preferred."),(0,l.yg)("h3",{id:"shared-properties"},"Shared Properties"),(0,l.yg)("p",null,"Except for the properties above, there are some extra properties which can be customized to meet different needs."),(0,l.yg)("table",null,(0,l.yg)("thead",{parentName:"table"},(0,l.yg)("tr",{parentName:"thead"},(0,l.yg)("th",{parentName:"tr",align:null},"Properties"),(0,l.yg)("th",{parentName:"tr",align:null},"Description"),(0,l.yg)("th",{parentName:"tr",align:null},"Default"),(0,l.yg)("th",{parentName:"tr",align:null},"Required"))),(0,l.yg)("tbody",{parentName:"table"},(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"druid.cache.password")),(0,l.yg)("td",{parentName:"tr",align:null},"Password to access redis server/cluster"),(0,l.yg)("td",{parentName:"tr",align:null},"None"),(0,l.yg)("td",{parentName:"tr",align:null},"no")),(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"druid.cache.expiration")),(0,l.yg)("td",{parentName:"tr",align:null},"Expiration for cache entries"),(0,l.yg)("td",{parentName:"tr",align:null},"P1D"),(0,l.yg)("td",{parentName:"tr",align:null},"no")),(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"druid.cache.timeout")),(0,l.yg)("td",{parentName:"tr",align:null},"Timeout for connecting to Redis and reading entries from Redis"),(0,l.yg)("td",{parentName:"tr",align:null},"PT2S"),(0,l.yg)("td",{parentName:"tr",align:null},"no")),(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"druid.cache.maxTotalConnections")),(0,l.yg)("td",{parentName:"tr",align:null},"Max total connections to Redis"),(0,l.yg)("td",{parentName:"tr",align:null},"8"),(0,l.yg)("td",{parentName:"tr",align:null},"no")),(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"druid.cache.maxIdleConnections")),(0,l.yg)("td",{parentName:"tr",align:null},"Max idle connections to Redis"),(0,l.yg)("td",{parentName:"tr",align:null},"8"),(0,l.yg)("td",{parentName:"tr",align:null},"no")),(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"druid.cache.minIdleConnections")),(0,l.yg)("td",{parentName:"tr",align:null},"Min idle connections to Redis"),(0,l.yg)("td",{parentName:"tr",align:null},"0"),(0,l.yg)("td",{parentName:"tr",align:null},"no")))),(0,l.yg)("p",null,"For ",(0,l.yg)("inlineCode",{parentName:"p"},"druid.cache.expiration")," and ",(0,l.yg)("inlineCode",{parentName:"p"},"druid.cache.timeout")," properties, values can be format of ",(0,l.yg)("inlineCode",{parentName:"p"},"Period")," or a number in milliseconds."),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-properties"},"# 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")),(0,l.yg)("h2",{id:"metrics"},"Metrics"),(0,l.yg)("p",null,"In addition to the normal cache metrics, the redis cache implementation also reports the following in both ",(0,l.yg)("inlineCode",{parentName:"p"},"total")," and ",(0,l.yg)("inlineCode",{parentName:"p"},"delta")),(0,l.yg)("table",null,(0,l.yg)("thead",{parentName:"table"},(0,l.yg)("tr",{parentName:"thead"},(0,l.yg)("th",{parentName:"tr",align:null},"Metric"),(0,l.yg)("th",{parentName:"tr",align:null},"Description"),(0,l.yg)("th",{parentName:"tr",align:null},"Normal value"))),(0,l.yg)("tbody",{parentName:"table"},(0,l.yg)("tr",{parentName:"tbody"},(0,l.yg)("td",{parentName:"tr",align:null},(0,l.yg)("inlineCode",{parentName:"td"},"query/cache/redis/*/requests")),(0,l.yg)("td",{parentName:"tr",align:null},"Count of requests to redis cache"),(0,l.yg)("td",{parentName:"tr",align:null},"whatever request to redis will increase request count by 1")))))}m.isMDXComponent=!0}}]);