{"id":438595,"date":"2021-04-14T14:45:43","date_gmt":"2021-04-14T06:45:43","guid":{"rendered":"http:\/\/4563.org\/?p=438595"},"modified":"2021-04-14T14:45:43","modified_gmt":"2021-04-14T06:45:43","slug":"%e8%af%b7%e6%95%99%e8%af%b8%e4%bd%8d%e4%b8%80%e4%b8%aa-redis-%e7%bb%9f%e8%ae%a1%e8%ae%bf%e9%97%ae%e9%87%8f%e5%a2%9e%e9%80%9f%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=438595","title":{"rendered":"\u8bf7\u6559\u8bf8\u4f4d\u4e00\u4e2a redis \u7edf\u8ba1\u8bbf\u95ee\u91cf\u589e\u901f\u7684\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559\u8bf8\u4f4d\u4e00\u4e2a redis \u7edf\u8ba1\u8bbf\u95ee\u91cf\u589e\u901f\u7684\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u81ea\u5df1\u641e\u4e86\u4e2a\u5c0f\u7a0b\u5e8f\uff0c\u9700\u8981\u7edf\u8ba1\u4e00\u4e0b\u67d0\u4e9b\u5185\u5bb9\u7684\u8bbf\u95ee\u91cf\u589e\u901f\uff0c\u6bd4\u5982\u67d0\u4e2a\u89c6\u9891 10 \u5206\u949f\u5185\u7684\u8bbf\u95ee\u91cf\uff0c\u5728\u5185\u5b58\u6709\u9650\u7684\u60c5\u51b5\u4e0b(\u6700\u591a 8g)\uff0c\u7528 redis \u6765\u505a\u7684\u8bdd\uff0c\u600e\u4e48\u505a\u6bd4\u8f83\u597d\uff1f\u56e0\u4e3a\u5b58\u5728\u65f6\u95f4\u7a97\u53e3\u7684\u95ee\u9898\uff0c\u4e0d\u77e5\u9053\u91c7\u7528\u54ea\u79cd\u65b9\u6cd5\u6bd4\u8f83\u597d\u3002<\/p>\n<p>\u5173\u4e8e\u7528\u6237\uff0c\u6ca1\u767b\u5f55\u4ec0\u4e48\u7684\uff0c\u6240\u4ee5\u4e5f\u4e0d\u4f1a\u6709\u4ec0\u4e48\u7528\u6237 id \u4e4b\u7c7b\u7684\u4e1c\u897f<\/p>\n<ol>\n<li>\u6709\u5e8f\u96c6\u5408\uff0c\u6beb\u79d2\u65f6\u95f4\u6233\u4e3a score\uff0c\u4f46\u662f\u5982\u679c\u6bd4\u8f83\u591a\u8bbf\u95ee\u7684\u8bdd\uff0c\u5185\u5b58\u5360\u7528\u6bd4\u8f83\u5927\uff0c\u5b9e\u9645\u4e0a\u6211\u53ea\u60f3\u8981\u4e00\u4e2a\u6570\u800c\u5df2<\/li>\n<li>\u666e\u901a\u7684 key\uff0c\u4f46\u662f\u600e\u4e48\u53bb\u9664 10 \u5206\u949f\u524d\u7684\u6570\u636e\uff1f\u6bcf\u5206\u949f\u5b58\u4e00\u6b21\u8bbf\u95ee\u91cf\u6570\u636e\u7684\u8bdd\uff0c\u8981\u7edf\u8ba1\u4e00\u4e2a\u89c6\u9891\u7684 10 \u5206\u949f\u8bbf\u95ee\u91cf\u8fd8\u597d\uff0c\u4f46\u662f\u8981\u7edf\u8ba1\u591a\u4e2a\u7684\u65f6\u5019\uff0c\u5c31\u8981\u591a\u6b21\u8bfb\u53d6 redis<\/li>\n<li>\u6709\u6ca1\u6709\u66f4\u597d\u7684\u529e\u6cd5? \u6210\u672c\u6709\u9650\uff0c\u52a0\u5185\u5b58\u4ec0\u4e48\u7684\u5c31\u5148\u4e0d\u8003\u8651\u4e86\u5427<\/li>\n<\/ol><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>48<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5750189\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jooooooooo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6bcf\u5206\u949f\u4e00\u4e2a key \u5457.<\/p>\n<p>key: view_count_{vid}_{minute}<\/p>\n<p>\u7136\u540e\u60f3\u7edf\u8ba1\u5341\u5206\u949f\u7684\u5c31\u635e\u5341\u4e2a key \u6c42\u548c                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750190\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : opengps <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u89c6\u9891 id+\u7528\u9014\u540e\u7f00\uff1a<br \/>\u4e00\u4e2a\u8ba1\u6570\u7f13\u5b58\uff1a\u6765\u4e86\u7edf\u8ba1\u8bf7\u6c42\u5c31\u81ea\u52a8\u52a0\u4e00\u3002\u6bcf\u5206\u949f\u8f6c\u5b58\u5230\u5f52\u6863<br \/>\u4e00\u4e2a hash \u5f52\u6863\u7f13\u5b58\uff1a\u6bcf\u5206\u949f\u5b58\u5165\u4e00\u4efd\u5206\u949f\u7ea7\u522b\u7edf\u8ba1\u3002<br \/>\u81f3\u4e8e\u5206\u6790\uff0c\u5c31\u53ea\u4ece\u5f52\u6863 hash \u91cc\u53d6\u503c\u7edf\u8ba1\uff0c\u6309\u7167\u5206\u949f key \u53bb\u770b\u6700\u8fd1\u5341\u5206\u949f\u7684\u7ed3\u679c\u3002\u7edf\u8ba1\u65f6\u5019\u4e3b\u8981\u4f9d\u9760 hash \u7684\u6279\u91cf\u547d\u4ee4\u64cd\u4f5c\u6765\u51cf\u5c11\u8bfb\u53d6\u6b21\u6570                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750191\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : carity <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u76f4\u63a5\u641e\u4e2a\u6570\u636e\u5e93\u5b58\u5457\uff0c\u8fd9\u6837\u4f60\u60f3\u600e\u4e48\u7edf\u8ba1\u90fd\u53ef\u4ee5\u4e86\uff0cmysql pgsql \u5360\u7528\u5185\u5b58\u4e5f\u4e0d\u5927                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750192\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Jooooooooo \u8fd9\u5c31\u662f\u6211\u63d0\u5230\u7684\u7b2c 2 \u79cd\u505a\u6cd5\u4e86~<br \/>\u4f46\u95ee\u9898\u662f\uff0c\u6211\u60f3\u505a\u4e00\u4e2a\u7ba1\u7406\u540e\u53f0\uff0c\u5728\u89c6\u9891\u5217\u8868\u4e0a\uff0c\u663e\u793a\u6bcf\u4e2a\u89c6\u9891\u7684\u8bbf\u95ee\u589e\u901f\uff0c\u5982\u679c\u6211\u4e00\u9875\u62ff 20 \u4e2a\u89c6\u9891\uff0c\u6bcf\u4e2a\u89c6\u9891\u635e 10 \u4e2a key\uff0c20 \u4e2a\u89c6\u9891\u5c31\u8981\u635e 200 \u4e2a key\uff0c\u867d\u7136\u8bf4\u7528 mget \u8bfb\u53d6\u4e5f\u53ea\u8981\u8bfb 20 \u6b21&#8230;.\u4f46\u6211\u89c6\u9891\u8d8a\u591a\uff0ckey \u5c31\u8d8a\u591a\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750193\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @carity \u6709\u6570\u636e\u5e93\uff0c\u4f46\u662f\u6bcf\u6b21\u89c6\u9891\u88ab\u8bbf\u95ee\u5c31\u76f4\u63a5\u5199\u6570\u636e\u5e93+1 \u5417\uff1f\u90a3\u5230\u65f6\u5019\u6570\u636e\u5e93\u5199\u538b\u529b\u5c31\u5f88\u5927\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750194\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : liujuzzz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             i                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750195\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @opengps \u6bcf\u5206\u949f\u8f6c\u5b58\u5230\u5f52\u6863\uff0c\u5f52\u6863\u6307\u7684\u662f mysql \u4e4b\u7c7b\u7684\u6570\u636e\u843d\u5730\u7684\u4e1c\u897f\uff1f<br \/>\u53e6\u5916\u6bcf\u5206\u949f\u8f6c\u5b58\u662f\u540e\u53f0\u8d77\u4e00\u4e2a\u811a\u672c\u6765\u505a\u8fd9\u4e2a\u5417\uff1f<br \/>hash \u5f52\u6863\u7f13\u5b58 \u5c31\u76f8\u5f53\u4e8e\u53ea\u7edf\u8ba1\u4e86 T-1 \u5206\u949f\u7684 \u8bbf\u95ee\u6570\uff0c\u8fd9\u4e2a\u5012\u53ef\u4ee5\u63a5\u53d7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750196\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @liujuzzz \u8fd9\u662f\u63d2\u773c\u7684\u610f\u601d\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750197\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jooooooooo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @waibunleung key \u591a\u4e0d\u8981\u7d27, \u67e5\u8be2\u505a\u597d\u5206\u9875\u5c31\u884c.                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750198\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ch2 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u4f1a\u4e0d\u4f1a\u9ad8\u4f30\u4e86\u5199\u538b\u529b\uff1f redis \u90fd\u4e0d\u9700\u8981\uff0c\u76f4\u63a5 mongo \u4e00\u4e2a\u8868\u5b58\u5c31\u884c\u4e86\uff0c\u67e5\u8be2\u4e5f\u597d\u67e5\u8be2\uff0c\u53cd\u6b63\u4f60\u8fd9\u4e2a\u8868\u7ed3\u6784\u5f88\u7b80\u5355\uff0c\u5c31\u89c6\u9891 id \u8ddf\u65f6\u95f4\u6233\u6216\u8005\u4f60\u518d\u52a0\u4e2a ip\uff0c\u8fd9\u79cd\u7b80\u5355\u7684\u6570\u636e\uff0cmongo \u5b58\u4e00\u4ebf\u6761\u4e5f\u65e0\u538b\u529b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750199\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tianshiyeben <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5c31\u662f\u76d1\u63a7\u6570\u636e\u589e\u91cf\u53d8\u5316\u5427 \u7528 http:\/\/www.wgstart.com \u6709\u6570\u636e\u76d1\u63a7\u6a21\u5757 \u4f1a\u5b9a\u671f\u626b\u63cf\u5e76\u751f\u6210\u8d8b\u52bf\u56fe\u8868                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750200\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tianshiyeben <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5fd8\u4e86\u8bf4\u4e86 \u524d\u63d0\u662f\u4f60\u5f97\u4ece\u6570\u636e\u5e93\uff08 mysql pgsql \u7b49\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff09\u7528 sql \u80fd\u635e\u5230\u6570\u636e                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750201\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ch2 \u76ee\u524d\u6ca1\u6709\u914d\u7f6e mongo\uff0cmongo \u5b58\u4e00\u4ebf\u6761\u78c1\u76d8\u5360\u7528\u8981\u53bb\u5230\u591a\u5c11\u5462\uff1f\u4e0d\u7528 redis \u7eaf\u7528 mongo \u6765\u627f\u8f7d\u8bfb\u5199\u7684\u8bdd\uff0cmongo \u5927\u6982\u80fd\u6297\u4f4f\u591a\u5927\u7684 qps \uff1f\u6709\u6ca1\u6709\u7a0d\u5fae\u5177\u4f53\u4e00\u70b9\u7684\u6570\u636e\u53ef\u4ee5\u652f\u6491\u4e00\u4e0b\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750202\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : seth19960929 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @waibunleung redis \u6709 pipe, \u4e00\u6b21\u5168\u90e8\u635e\u51fa\u6765                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750203\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @seth19960929 \u6211\u77e5\u9053\u8fd9\u4e2a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750204\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dzdh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u786c\u76d8\u5141\u8bb8\u7684\u8bdd\u641e\u4e2a\u5355\u673a\u7684\u65f6\u5e8f\u6570\u636e\u5e93\u54c7\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750205\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ch2 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @waibunleung #13 \u5982\u679c\u53ea\u5b58\u6211\u8bf4\u7684\u90a3\u4e09\u4e2a\u5b57\u6bb5\uff0c\u5927\u6982\u4e0d\u5230 5G \u3002\u5199\u7684\u8bdd qps \u51e0\u5343\u80af\u5b9a\u6ca1\u95ee\u9898\u7684\uff0c\u8bfb\u53d6\u7684\u8bdd\u4f60\u53ef\u4ee5\u7528 redis \u7f13\u5b58\u7ed3\u679c\uff0c1 \u5206\u949f\u5168\u8868\u67e5\u8be2\u4e00\u6b21\u5c31\u80fd\u5f97\u5230\u7edf\u8ba1\u7ed3\u679c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750206\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : opengps <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @waibunleung \u6211\u8bf4\u7684\u5f52\u6863\u5c31\u662f\u7b2c\u4e00\u4e2a key \u4e0b\u4ea7\u751f\u7684\u5206\u949f\u7ea7\u6570\u636e\uff0c\u5b58\u5165\u7b2c\u4e8c\u4e2a key \u4e0b\u5f53\u5f52\u6863\u6570\u636e\uff0c\u7136\u540e\u5206\u6790\u65f6\u5019\u4f7f\u7528\u7b2c\u4e8c\u4e2a key                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750207\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vebuqi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9047\u5230\u8fc7\u7c7b\u4f3c\u7684\u95ee\u9898\uff0c\u8bf4\u4e0b\u89e3\u51b3\u7684\u65b9\u6cd5<\/p>\n<p>\u5047\u8bbe\u6211\u4eec\u9700\u8981\u5b58\u50a8\u89c6\u9891\u8fd1 10 \u5206\u949f\u5185\u7684\u8bbf\u95ee\u91cf<\/p>\n<p>\u5b58\u50a8\u65b9\u9762\uff0c\u6211\u4eec\u53ef\u4ee5\u628a 10 \u5206\u949f\uff0c\u5206\u5272\u6210 10 \u4e2a 1 \u5206\u949f\uff0c\u4f7f\u7528 Redis \u7684 bitmap \u6765\u5b58\u50a8\u8fd9 10 \u4e2a\u91cf<\/p>\n<p>\u5728\u547d\u4ee4\u65b9\u9762\uff0credis \u7684 BITFIELD \u547d\u4ee4\u53ef\u4ee5\u5bf9 bitmap \u7684\u591a\u4e2a\u57df\u540c\u65f6\u64cd\u4f5c\uff0c\u5bf9\u6bcf\u4e2a\u57df\u652f\u6301 GET \u3001SET \u3001INCRBY \u5b50\u547d\u4ee4\uff0c\u53ef\u4ee5\u6ee1\u8db3\u9700\u6c42<\/p>\n<p>\u5982\u56fe\uff1a<\/p>\n<p>![image.png]( https:\/\/i.loli.net\/2021\/04\/10\/LBkiMupGR6ctXoT.png)<\/p>\n<p>\u6211\u4eec\u628a bitmap \u5206\u5272\u6210 10 \u4e2a\u57df\uff0c\u6bcf\u4e2a\u57df\u4ee3\u8868 1 \u5206\u949f\u7684\u8bbf\u95ee\u91cf\uff0c\u90a3\u4e48\u6bcf\u6b21\u83b7\u53d6\u67d0\u4e2a\u89c6\u9891\u7684\u8bbf\u95ee\u91cf\u65f6\uff0c\u53ef\u4ee5\u53d6\u5230\u8fd9 10 \u4e2a\u57df\u7684\u503c\u6c42\u548c\u5373\u53ef<\/p>\n<p>\u5047\u8bbe\u6bcf\u5206\u949f\u89c6\u9891\u7684\u8bbf\u95ee\u91cf\u7684\u4e0a\u9650\u662f 255 \uff08 2^8\uff0c\u8fd9\u91cc\u662f\u4e3a\u4e86\u63a7\u5236\u6ea2\u51fa\uff0c\u503c\u53ef\u4ee5\u65e0\u9650\u5927\u5c0f\uff0c\u53ea\u8981\u662f 2 \u7684\u6b63\u6574\u6570\u500d\u5373\u53ef\uff09<\/p>\n<p>\u65b0\u589e\u8bbf\u95ee\u91cf\u65f6\uff0c\u53ea\u9700\u8ba1\u7b97\u5e94\u8be5\u5f80\u54ea\u4e2a \/\u54ea\u4e9b\u57df\uff08 offset \uff09\u91cc\u589e\u52a0\u5c31\u53ef\u4ee5\u4e86\uff0c\u5982 22:13 \u7684\u89c6\u9891 123456 \u7684\u8bbf\u95ee\u91cf\u65b0\u589e 17\uff0c\u6839\u636e\u65f6\u95f4\u8ba1\u7b97 offset \u4e3a 3\uff0c\u547d\u4ee4\uff1a<\/p>\n<p>`BITFIELD v:123456:cnt:bit OVERFLOW SAT INCRBY u8 0 17<\/p>\n<p>\u8fd9\u6761\u547d\u4ee4\u8fd4\u56de\u5bf9 offset \u4e3a 0 \u7684\u57df\u8fdb\u884c\u4e86+17 \u7684\u64cd\u4f5c\uff0cu8 \u8868\u793a\u6309\u7167 10 \u4e2a bit \u5206\u57df\uff0c\u4e0a\u9650 255\uff0c0 \u6807\u8bc6 offset\uff0c\u5373\u7b2c 0 \u5206\u949f\uff0c`OVERFLOW SAT`\u8868\u793a\u5982\u679c incr \u540e\u7684\u7ed3\u679c\u8d85\u8fc7\u4e0a\u9650\uff08\u8fd9\u91cc\u662f 2^8 \uff09\uff0c\u90a3\u4e48\u7ed3\u679c\u4fdd\u6301\u5728\u6700\u5927\u503c 255 \uff08 8 \u4f4d\u5168 1 \uff09<\/p>\n<p>\u83b7\u53d6\u89c6\u9891 123456 \u8fd1 10 \u5206\u949f\u7684\u8bbf\u95ee\u91cf\uff0c\u547d\u4ee4\uff1a<\/p>\n<p>`BITFIELD v:123456:cnt:bit GET u8 GET u8 1 GET u8 2 GET u83 GET u8 4 GET u8 5 GET u8 6 GET u8 7 GET u8 8 GET u8 9`<\/p>\n<p>\u8fd9\u6761\u547d\u4ee4\u4f1a\u8fd4\u56de\u6bcf\u4e2a\u57df\uff08\u5373\u6bcf\u5206\u949f\uff09\u7684\u503c\uff0c\u6c42\u548c\u540e\u5373\u4e3a\u8fd1 10 \u5206\u949f\u7684\u7d2f\u8ba1\u8bbf\u95ee\u91cf<\/p>\n<p>BITFIELD \u7684\u6bcf\u4e2a\u5b50\u547d\u4ee4\u7684\u590d\u6742\u5ea6\u662f O(1)\u7684\uff0c\u5982\u679c\u8bbf\u95ee \/\u64cd\u4f5c N \u4e2a\u89c6\u9891\u7684\u8fd1 10 \u5206\u949f\u7684\u8bbf\u95ee\u91cf\uff0c\u4e5f\u5c31\u662f\u64cd\u4f5c N \u6b21 Redis \u5373\u53ef<\/p>\n<p>\u65b9\u6848\u7684\u4f18\u70b9<\/p>\n<p>1. \u7701\u7a7a\u95f4\uff0cbitmap \u5360\u7528\u7a7a\u95f4\u5f88\u5c0f<br \/>2. \u652f\u6301\u6279\u91cf\uff0cBITFIELD \u7684\u5b50\u547d\u4ee4\u53ef\u4ee5\u591a\u4e2a\u540c\u65f6\u64cd\u4f5c<\/p>\n<p>\u7f3a\u70b9\uff1a<\/p>\n<p>1. \u4e0d\u662f\u4e25\u683c\u7684\u6ed1\u52a8\u7a97\u53e3\uff0c\u6709\u4e00\u5b9a\u7684\u7cbe\u5ea6\u635f\u5931<\/p>\n<p> \u8fd9\u4e2a\u53ef\u4ee5\u901a\u8fc7\u62c6\u7ec6\u7c92\u5ea6\u6765\u89e3\u51b3\uff0c\u5982 10 \u79d2\uff08\u751a\u81f3 1 \u79d2\uff09\u4e00\u4e2a\u57df\uff0c\u76f8\u5e94\u5730\uff0c\u8fd9\u6837\u4f1a\u589e\u52a0\u4e00\u5b9a\u7684\u5b58\u50a8<\/p>\n<p>2. \u8bbe\u8ba1\u65f6\u9700\u8981\u8003\u8651\u5355\u4e2a\u5355\u4f4d\u65f6\u95f4\u5185\u7684\u4e0a\u9650\uff0c\u8d85\u8fc7\u4e0a\u9650\u65f6\uff0c\u7edf\u8ba1\u4e0d\u51c6\uff0c\u56e0\u4e3a\u6211\u4eec\u5728\u6ea2\u51fa\u63a7\u5236\u65f6\u4f7f\u7528\u4e86\u9971\u548c\u7b97\u6cd5\uff08 SAT \uff09<\/p>\n<p> \u8fd9\u4e2a\u53ef\u4ee5\u5728\u8bbe\u8ba1\u521d\u671f\u5c3d\u91cf\u9884\u7559\u4e00\u4e2a\u4fdd\u9669\u7684\u503c\uff0c\u5f53\u7136\u4e86\uff0c\u8d8a\u5927\u7684\u8bdd\uff0c\u5b58\u50a8\u4e5f\u4f1a\u8d8a\u5927<\/p>\n<p>3. \u5bf9\u4e8e\u8bfb\u5199\u5206\u79bb\u7684\u573a\u666f\uff08\u5373\u8bfb\u4ece\u5199\u4e3b\uff09\uff0cBITFIELD \u88ab Redis \u6807\u8bc6\u4e3a\u5199\u547d\u4ee4\uff0c\u6240\u4ee5\u6240\u6709\u7684 BITFIELD \u90fd\u4f1a\u5728\u4e3b\u8282\u70b9\u4e0a\u6267\u884c<\/p>\n<p> \u8fd9\u4e2a\u95ee\u9898\u6211\u4eec\u9047\u5230\u4e86\uff0c\u4f46\u6ca1\u6709\u9020\u6210\u5f88\u9ad8\u7684\u8d1f\u8f7d\uff0c\u6240\u4ee5\u6ca1\u6709\u5904\u7406\uff1b\u4e0d\u8fc7\u963f\u91cc\u4e91\u6709\u7bc7\u6587\u7ae0\u53ef\u4ee5\u53c2\u8003\uff1a https:\/\/developer.aliyun.com\/article\/757841                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750208\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ch2 \u8fd9\u79cd\u65b9\u6848\u7684\u8bdd\uff0c\u8fd8\u4e0d\u5982\u5148\u5199\u5230 redis \u4e00\u5206\u949f\u540c\u6b65\u4e00\u6b21\u6570\u636e\u5230 mysql\uff0c\u57fa\u672c\u6ca1\u6709\u5199\u538b\u529b\uff0c\u65b9\u6848\u4e0a\u66f4\u8d8b\u8fd1\u4e8e\u8fd9\u4e2a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750209\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @opengps \u55ef\u55ef\uff0c\u8fd9\u79cd\u53ef\u4ee5\u8003\u8651\u4e00\u4e0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750210\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @vebuqi \u770b\u61c2\u4e86\u5927\u90e8\u5206\uff0c\u4f46\u7591\u95ee\u662f\u4e0b\u4e00\u4e2a 10 \u5206\u949f\u7684\u65f6\u95f4\u7a97\u53e3\uff0c\u662f\u53e6\u8d77\u65b0\u7684 key \u7edf\u8ba1\u5417\uff1f\u8fd8\u662f\u5c06\u65e7\u7684\u6e05\u96f6\uff1f\u6bd4\u5982 10:59 \u5206 \u8fc7\u6e21\u5230 11:00 \u7684\u65f6\u5019\uff0c\u6b64\u65f6 bitmap \u4e0a 0 \u8fd9\u4e2a field \u8fd8\u662f\u5b58\u50a8\u7740 10:50 \u7684\u7edf\u8ba1\uff1f\u8fd8\u662f\u600e\u4e48\u6837                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750211\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : angryfish <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8fd9\u5c0f\u7a0b\u5e8f\u591a\u5927\u7684\u91cf\uff0c\u8fd8\u62c5\u5fc3\u6570\u636e\u5e93\u5199\u5165\u592a\u9891\u7e41\u3002\u7528\u6237\u8bbf\u95ee\u4e00\u6b21\uff0c\u5199\u5165\u4e00\u6761\u8bb0\u5f55\uff0c\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u6ca1\u4ec0\u4e48\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750212\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : keakon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u603b\u89c6\u9891\u6570\u3001\u6bcf 10 \u5206\u949f\u603b\u7684\u8bbf\u95ee\u91cf\u8bf4\u4e0b\u91cf\u7ea7\u5427\uff0c\u5e94\u7528\u573a\u666f\u662f\u600e\u6837\u7684\uff0c\u611f\u89c9\u4f60\u60f3\u5f97\u592a\u591a\u4e86\u3002<\/p>\n<p>\u6bd4\u5982\u300c\u6211\u60f3\u505a\u4e00\u4e2a\u7ba1\u7406\u540e\u53f0\u2026\u300d\uff0c\u4f60\u7ba1\u7406\u540e\u53f0\u6bcf\u79d2\u80fd\u5237\u51e0\u5343\u6b21\u554a\uff0c\u8fd8\u80fd\u88ab\u5237\u7206\uff1f<\/p>\n<p>\u800c\u5982\u679c\u662f\u9762\u5411\u516c\u4f17\u7528\u6237\u7684\u573a\u666f\uff0c\u4f60\u7684\u9700\u6c42\u4e5f\u4e0d\u9700\u8981\u300c\u5b9e\u65f6\u3001\u7cbe\u786e\u5730\u8ba1\u7b97\u51fa\u8bbf\u95ee\u589e\u91cf\u300d\uff0c\u6bcf\u5206\u949f\u7edf\u8ba1\u4e00\u4e0b\u5c31\u884c\u4e86\u3002<\/p>\n<p>\u6700\u540e\uff0c\u8fd9\u79cd\u60c5\u51b5\u6bd4\u8f83\u5e38\u89c1\u7684\u505a\u6cd5\u662f\u4f7f\u7528\u65f6\u95f4\u8f6e\uff0c\u6bd4\u5982\u9009\u4e00\u4e2a\u6bd4 10 \u5927\u53c8\u80fd\u88ab 60 \u6574\u9664\u7684\u6570\uff0c\u4f8b\u5982 12 \u3002\u5c06\u5f53\u524d\u7684\u5206\u949f\u6570\u5bf9 12 \u53d6\u6a21\uff0c\u7136\u540e\u6bcf\u4e2a key \u8bb0\u5f55\u8fd9\u4e00\u5206\u949f\u7684\u6570\u636e\u3002\u6bcf\u5230\u4e00\u4e2a\u65b0\u7684\u4e00\u5206\u949f\uff0c\u5c31\u628a 11 \u5206\u949f\u524d\u7684 key \u5220\u4e86\u3002\u8981\u83b7\u53d6\u6570\u636e\u65f6\uff0c\u5c31\u53d6\u5f53\u524d\u548c\u4e4b\u524d\u7684 10 \u4e2a key \u3002<br \/>\u81f3\u4e8e\u6570\u636e\u7ed3\u6784\u9009\u5565\uff0c\u6839\u636e\u4f60\u7684\u89c6\u9891\u91cf\u7ea7\u3001\u89c6\u9891\u6570\u662f\u5426\u6052\u5b9a\u3001id \u662f\u5426\u8fde\u7eed\u7b49\u800c\u5b9a\uff0c\u4e0d\u540c\u7684\u65b9\u6848\u5185\u5b58\u5dee\u522b\u5f88\u5927\u3002\u6bd4\u5982\u4e00\u63d0\u5230\u7684 view_count_{vid}_{minute}\uff0c\u8fd9\u79cd\u5b9e\u73b0\u4e0d\u7528\u770b\u4e5f\u77e5\u9053\u5185\u5b58\u625b\u4e0d\u4f4f\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750213\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xuanbg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 hash \u7c7b\u578b\u5b58\u50a8\uff0c\u6bcf\u4e2a\u6587\u4ef6\u4e00\u4e2a key \u3002\u8fd9\u4e2a key \u4e0b\u9762\u6bcf 10 \u5206\u949f\u65b0\u589e\u4e00\u4e2a hash key\uff0c\u5728\u8fd9\u4e2a\u65f6\u95f4\u6bb5\u91cc\uff0c\u6bcf\u8bbf\u95ee\u4e00\u6b21\u8fd9\u4e2a hash key \u7684 value +1 \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750214\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vebuqi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @waibunleung <\/p>\n<p>\u5355\u4e2a\u89c6\u9891\u7684\u8bbf\u95ee\u91cf\u7528\u4e24\u4e2a key \u6765\u5b58\u50a8\uff0c\u8fc7\u671f\u65f6\u95f4\u8bbe\u7f6e\u6210\u4e24\u4e2a\u5468\u671f\uff0c\u4e5f\u5c31\u662f 20 \u5206\u949f<br \/>\u5199\u5165\u65f6\uff0c\u6bcf\u6b21\u90fd\u5bf9\u5f53\u524d\u5468\u671f\u5185\u7684 key \u5199\u5165<br \/>\u8bfb\u53d6\u65f6\uff0c\u8bfb\u53d6\u4e0a\u4e2a\u5468\u671f\u7684\u540e\u534a\u90e8\u5206\u548c\u8fd9\u4e2a\u5468\u671f\u7684\u524d\u534a\u90e8\u5206<\/p>\n<p>\u5982\uff1a<br \/>\u73b0\u5728\u662f 10:56\uff0c\u5219\u76ee\u524d\u6570\u636e\u5e93\u4e2d\u7684 key \u6709\u4e24\u4e2a\uff0cv:${id}:cnt:bit:1040 \uff08\u8fc7\u671f\u65f6\u95f4\u8fd8\u6709 4 \u5206\u949f\uff09 \u548c v:${id}:cnt:bit:1050 \uff08\u8fc7\u671f\u65f6\u95f4\u8fd8\u6709 14 \u5206\u949f\uff09\uff0c1040 \u4ee3\u8868 10:4X \u5468\u671f\u5185\u7684\u8ba1\u6570\uff0c10:50 \u4ee3\u8868 10:5X \u5468\u671f\u5185\u7684\u8ba1\u6570<\/p>\n<p>\u82e5 10:56 \u65b0\u589e 10 \u4e2a\uff0c\u5219\u5bf9 v:${id}:cnt:bit:1050 \u5185\u7b2c 6 \u4e2a\u57df incr 10 \u5373\u53ef<br \/>\u82e5\u8bfb\u53d6\u6700\u8fd1 10min \u7684\u8bbf\u95ee\u91cf\uff0c\u5219\u53d6\u524d\u4e00\u4e2a key \u7684\u540e 3 \u4e2a\u57df\uff08 10:47 \u300110:48 \u300110:49 \uff09\u548c\u5f53\u524d key \u7684\u524d 7 \u4e2a\u57df\uff08 10:50 ~ 10:56 \uff09\uff0c\u7136\u540e\u6c42\u548c<\/p>\n<p>\u8fd9\u6837\u7684\u8bdd\u5c31\u907f\u514d\u4e86\u4f60\u63d0\u5230\u7684\u95ee\u9898\uff0c\u4f46\u589e\u52a0\u4e86\u4e00\u500d\u7684\u5b58\u50a8\uff08\u4e24\u4e2a key \uff09<\/p>\n<p>\u518d\u590d\u6742\u4e00\u70b9\u7684\u65b9\u6848\uff0c\u5355 key \u4e2d\u524d N \u4f4d\u7528 1 \u4e2a\u5355\u72ec\u7684\u57df\uff0c\u8bb0\u5f55\u4e0a\u6b21\u5199\u5165\u65f6\u95f4\uff0c\u6bcf\u6b21\u5199\u5165\u524d\uff0c\u6839\u636e\u5f53\u524d\u65f6\u95f4\u548c\u4e0a\u6b21\u5199\u5165\u65f6\u95f4\u5224\u65ad\u662f\u5426\u8981\u91cd\u7f6e\u4e4b\u524d\u7684\u67d0\u4e2a \/\u67d0\u4e9b\u57df\uff0c\u7136\u540e\u518d\u8fdb\u884c\u5199\u5165+\uff08\u91cd\u7f6e\uff09\u7684\u64cd\u4f5c\u3002\u8fd9\u6837\u7684\u8bdd\uff0c\u5b58\u50a8\u80fd\u964d\u5230\u4e00\u4e2a key\uff0c\u4f46\u5199\u5165\u65f6\u591a\u4e86\u4e00\u6b21\u64cd\u4f5c\uff0c\u65f6\u95f4\u6362\u7a7a\u95f4\u4e86\uff0c\u9002\u7528\u4e8e \u5199\u5c11\u8bfb\u591a\u7684\u573a\u666f\uff0c\u6240\u4ee5\u6700\u597d\u662f\u805a\u5408\u5199                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750215\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : luzhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6bcf\u6b21\u8bf7\u6c42\u5199\u5230 log \u91cc\u7528 shell \u7edf\u8ba1\u90fd\u5f88\u5feb\u7684\u3002\u5148\u5b9e\u73b0\u51fa\u6765\uff0c\u7136\u540e\u5728\u770b\u6ee1\u8db3\u4e0d\u6ee1\u8db3\u6027\u80fd\u8981\u6c42\u548c\u529f\u80fd\u9700\u6c42\uff0c\u7136\u540e\u5728\u770b\u600e\u4e48\u4f18\u5316\u6539\u8fdb\u65b9\u6848\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750216\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @angryfish \u65e5\u6d3b\u76ee\u524d\u5728 1w \u591a\u6709\uff0c\u9884\u8ba1\u4f1a\u589e\u957f\u81f3 10w                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750217\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @keakon \u5c31\u7b97\u7528\u4e00\u7684\u529e\u6cd5\uff0c\u6bcf\u5206\u949f\u4e5f\u53ea\u662f\u540c\u4e00\u4e2a\u666e\u901a\u7684 key \u3002\u800c\u4e14\u4e5f\u4f1a\u5220\u6389\uff0c\u201d\u4e0d\u7528\u770b\u4e5f\u77e5\u9053\u5185\u5b58\u625b\u4e0d\u4f4f\u201c \u662f\u4e0d\u662f\u592a\u6b66\u65ad\u4e86\u4e9b&#8230;.\u6211\u89c9\u5f97\u6297\u4f4f\u662f\u6ca1\u6709\u95ee\u9898\u7684&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750218\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @xuanbg \u90a3\u8fd9\u6837\u5b50\u5c31\u6ca1\u6709\u4e86\u65f6\u95f4\u6ed1\u52a8\u7a97\u53e3\u4e86\uff0c\u6211\u4e5f\u4e0d\u4f1a\u95ee\u8fd9\u4e2a\u95ee\u9898\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750219\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @luzhh \u662f\u7684\uff0c\u4eca\u5929\u60f3\u5230\u4e86\u8fd9\u4e2a\uff0c\u76f4\u63a5\u89e3\u6790 nginx \u7684 log \u4e5f\u662f\u4e2a\u529e\u6cd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750220\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : luzhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6216\u8005\u5c06\u6bcf\u4e00\u6761\u89c6\u9891\u64ad\u653e\u8bf7\u6c42\u53d1\u5230\u961f\u5217\u7528 flink \u7684\u6ed1\u52a8\u7a97\u53e3\u53bb\u7edf\u8ba1\uff0c\u4f60\u90a3\u670d\u52a1\u5668\u7684\u914d\u7f6e\u5e72\u8fd9\u4e2a\u5b8c\u5168\u4e0d\u5728\u8bdd\u4e0b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750221\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xuanbg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @waibunleung \u4f60\u8981\u600e\u6837\u6ed1\u52a8\uff1f\u4ee5\u4ec0\u4e48\u4e3a\u5355\u4f4d\uff1f\u8981\u4ee5\u5206\u949f\u4e3a\u5355\u4f4d\u6ed1\u52a8\uff0c\u6309\u5206\u949f\u8ba1\u6570\uff0c\u6309\u79d2\u6ed1\u52a8\u5c31\u6309\u79d2\u8ba1\u6570\u3002\u4e0d\u8fd8\u662f\u4e00\u6837\u7684\u9053\u7406\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750222\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : siweipancc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @vebuqi \u6700\u8fd1\u6709\u4e2a\u7c7b\u4f3c\u7684\u9700\u6c42\uff0c\u611f\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750223\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : billlee <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bf4\u4e2a 100K QPS \u7ea7\u7684\u65b9\u6848\uff1a<\/p>\n<p>1. \u5728\u5185\u5b58\uff08\u6216 redis \uff09\u91cc\u8bb0\u6570\uff0c\u5b9a\u65f6 (\u6bd4\u5982 10s) flush \u5230\u6301\u4e45\u5b58\u50a8 (mysql \u6216 influxdb) \u5e76 reset \u5185\u5b58\u4e2d\u7684\u8ba1\u6570\u5668<br \/>2. \u67e5\u8be2\u7684\u65f6\u5019\u5c31\u662f\u6307\u5b9a\u65f6\u95f4\u8303\u56f4 SUM() \u805a\u5408\u4e86<br \/>3. \u5b9a\u671f\u6e05\u7406\u6301\u4e45\u5b58\u50a8\u4e2d\u7684\u5386\u53f2\u6570\u636e<br \/>4. \u5982\u679c\u9700\u8981\u4fdd\u7559\u957f\u65f6\u95f4\u5386\u53f2\u6570\u636e\uff0c\u9700\u8981\u5728\u6301\u4e45\u5b58\u50a8\u90a3\u7aef\u505a\u964d\u91c7\u6837<\/p>\n<p>\u5173\u952e\u662f 1. \u5199\u5165\u7684\u65f6\u5019\u4e0d\u8981\u6bcf\u6b21\u8bf7\u6c42\u90fd\u843d\u76d8 2. \u67e5\u8be2\u7684\u65f6\u5019\u8981\u80fd\u7528\u4e0a rdbms \u7684\u67e5\u8be2\u80fd\u529b                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750224\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : liuhan907 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u662f\u5355\u7eaf\u7684\u7edf\u8ba1\u589e\u901f\uff0c\u90a3\u7528\u65f6\u5e8f\u6570\u636e\u5e93\u4e0d\u662f\u5f88\u5408\u9002\u4e48\uff1f\u6bd4\u5982\u7528\u5f00\u6e90\u7248\u7684 influxdb \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750225\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @xuanbg \u6362\u6210\u4e00\u5206\u949f\u4e4b\u540e\uff0c\u90a3\u8fd9\u4e0d\u5c31\u662f\u4e00\u8bf4\u7684\u90a3\u79cd\u505a\u6cd5\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750226\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xuanbg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @waibunleung \u4e3b\u4f60\u6709\u6ca1\u6709\u641e\u6e05\u695a\u81ea\u5df1\u7684\u9700\u6c42\uff1f\u9700\u6c42\u786e\u5b9a\u4e86\uff0c\u6570\u636e\u7ed3\u6784\u81ea\u7136\u5c31\u80fd\u786e\u5b9a\u4e86\u3002\u6570\u636e\u7ed3\u6784\u786e\u5b9a\u4e86\uff0c\u5b58\u50a8\u65b9\u6848\u81ea\u7136\u5c31\u80fd\u786e\u5b9a\u4e86\u3002\u5373\u4f7f\u6709\u95ee\u9898\uff0c\u81f3\u4e8e\u8fde\u95ee\u9898\u662f\u4ec0\u4e48\u90fd\u8bf4\u4e0d\u6e05\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750227\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @billlee \u55ef\u55ef\uff0c\u6709\u60f3\u8fc7\u8fd9\u4e2a\u65b9\u6cd5\uff0c\u5386\u53f2\u6570\u636e\u53ef\u4ee5\u653e\u5230\u51b7\u6570\u636e\u8868\uff0c\u4f46\u662f\u8fd9\u79cd\u65b9\u6cd5\u5982\u679c\u8981\u67e5\u66f4\u957f\u7684\u8fd1 x \u5206\u949f\u65f6\u95f4\u7684\u6570\u636e\uff0c\u89c6\u9891\u8d8a\u591a\uff0c\u5b58\u50a8\u91cf\u5c31\u8d8a\u591a\u4e86\uff0c\u4e0d\u77e5\u9053\u4f60\u8fd9\u4e2a\u91cf\u7ea7\uff0c\u4e00\u4e2a\u56fa\u5b9a\u65f6\u95f4\u5185(\u6bd4\u5982 1 \u4e2a\u5c0f\u65f6)\uff0c\u6301\u4e45\u5b58\u50a8\u91cc\u9762\u7684\u8bb0\u5f55\u6570\u6709\u591a\u5c11\uff1f\u5b58\u50a8\u7ed3\u6784\u662f\u600e\u4e48\u6837\u7684\uff1f<br \/>\u6bd4\u5982 10s flush \u4e00\u6b21\u5230 db \u7684\u8bdd\uff0c\u4e00\u5206\u949f\u5c31\u76f8\u5f53\u4e8e\u6709 6 \u6761\u8bb0\u5f55\u4e86\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750228\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @xuanbg \u804a\u573a\u5916\u5c31\u6ca1\u610f\u601d\u4e86\uff0c\u9700\u6c42\u63cf\u8ff0\u5f97\u633a\u6e05\u695a\u7684\u4e86\uff0c\u5c31\u662f\u8981\u5728\u5185\u5b58\u6709\u9650\u7684\u60c5\u51b5\u4e0b\u7528 redis \u7edf\u8ba1\u8fd1 10 \u5206\u949f\u7684\u6570\u636e\uff0c\u505a\u6cd5\u4e0d\u540c\u6570\u636e\u7ed3\u6784\u4e0d\u540c\uff0c\u4f60\u540e\u9762\u8bf4\u7684\u8fd9\u79cd\u505a\u6cd5\u548c\u4e00\u4e8c\u8bf4\u51fa\u6765\u7684\u6ca1\u6709\u672c\u8d28\u7684\u533a\u522b\uff0c\u95ee\u9898\u4e5f\u5728\u63cf\u8ff0\u7684\u5730\u65b9\u8bf4\u4e86\uff0c\u5b58\u5728\u6ed1\u52a8\u7a97\u53e3\u7684\u95ee\u9898\uff0c\u4f60\u7684\u7b2c\u4e00\u6761\u56de\u590d\u672c\u8d28\u662f\u56fa\u5b9a\u7684\u65f6\u95f4\u7a97\u53e3\uff0c\u6211\u53ea\u662f\u56de\u590d\u4f60\u8fd9\u6837\u505a\u7684\u8bdd\u4e0d\u6ee1\u8db3\u6211\u7684\u9700\u6c42\uff0c\u8bf7\u95ee\u600e\u4e48\u770b\u51fa\u6211\u4e0d\u4e86\u89e3\u9700\u6c42\u548c\u6570\u636e\u7ed3\u6784\u7684\u95ee\u9898\u5462\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750229\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @liuhan907 \u55ef\u55ef\u6211\u52a0\u5165\u5907\u5fd8\u7814\u7a76\u4e00\u4e0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750230\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : keakon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @waibunleung \u4f60\u6700\u597d\u5148\u719f\u6089 redis \u7684\u5185\u5b58\u5360\u7528\u518d\u6765\u81c6\u6d4b\u3002\u4e00\u7684\u65b9\u6848\u5185\u5b58\u5360\u7528\u8981\u591a 1~2 \u4e2a\u6570\u91cf\u7ea7\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750231\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @keakon \u5173\u952e\u662f\u6211\u6ca1\u6709\u770b\u51fa\u6765\u4f60\u7684\u65b9\u6848\u548c\u4e00\u7684\u65b9\u6848\u6709\u4ec0\u4e48\u672c\u8d28\u7684\u533a\u522b\uff0c\u81c6\u6d4b\u5012\u6ca1\u6709\uff0c\u4f60\u8bf4\u625b\u4e0d\u4f4f\u4e5f\u8981\u8bf4\u8bf4\u4f60\u7684\u7406\u7531\u548c\u5206\u6790\u5427\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750232\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @keakon \u5bf9\u4e0d\u8d77\uff0c\u4e00\u5f00\u59cb\u6ca1\u6709 get \u5230\u4f60\u5168\u90e8\u7684\u610f\u601d\uff0c\u6211\u4e4b\u6240\u4ee5\u4f1a\u8fd9\u4e48\u8bf4\uff0c\u662f\u56e0\u4e3a\u7528\u4e00\u7684\u65b9\u6848\uff0c\u4e5f\u53ef\u4ee5\u505a\u5230\u4f60\u8bf4\u7684\u65f6\u95f4\u8f6e\u7684\u7c7b\u4f3c\u6548\u679c\uff0c\u53ea\u662f\u4e00\u5c11\u4e86\u5b9a\u65f6\u5220\u9664\u65e7\u7f13\u5b58\u7684\u505a\u6cd5\uff0c\u52a0\u4e0a\u4e4b\u540e\uff0c\u6211\u89c9\u5f97\u548c\u4f60\u8bf4\u7684\u6ca1\u6709\u592a\u672c\u8d28\u7684\u533a\u522b\uff0c\u59cb\u7ec8\u7ef4\u62a4\u7684\u662f\u4e00\u4e2a\u65f6\u95f4\u6bb5\u5185\u7684\u6570\u636e                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750233\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sunhuawei <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u9700\u6c42\u6709\u70b9\u4e91\u91cc\u96fe\u91cc\u7684\uff0c\u5982\u679c\u662f\u6211\u7684\u8bdd\u6211\u4f1a\u7528 HyperLogLog \u7edf\u8ba1\uff0c\u6700\u5927\u5360\u7528 12k\uff0c\u4f1a\u6709 0.81%\u5de6\u53f3\u7684\u8bef\u5dee\u4f46\u5f88\u9ad8\u6548                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750234\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @sunhuawei \u8981\u5728\u5185\u5b58\u6709\u9650\u7684\u60c5\u51b5\u4e0b\u7528 redis \u7edf\u8ba1\u8fd1 10 \u5206\u949f\u7684\u89c6\u9891\u8bbf\u95ee\u91cf\uff0c\u8f6c\u53d1\u6570\u7b49\u6570\u636e\uff0cHyperLogLog \u4e3b\u8981\u662f\u53bb\u91cd\uff0c\u573a\u666f\u4e0d\u5bf9                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750235\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 11373450 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             redis \u8bbe\u7f6e\u4e00\u4e2a\u8fc7\u671f\u65f6\u95f4\uff08 10 \u5206\u949f\uff09\uff0c\u7136\u540e\u8bbe\u7f6e\u4ed6\u503c\u4e3a 1 \u3002 \u5224\u65ad\u8fd9\u4e2a redis \u5b58\u5728\u5c31\u7d2f\u52a0\u3002\u6ca1\u6709\u5b58\u5728\u5c31\u91cd\u65b0\u8bbe\u7f6e                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750236\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : waibunleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @11373450 \u8fd9\u79cd\u4e0d\u592a\u7b26\u5408\u65f6\u95f4\u6ed1\u52a8\u7a97\u53e3\u7684\u9700\u6c42\u54c8                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u8bf8\u4f4d\u4e00\u4e2a redis \u7edf\u8ba1\u8bbf\u95ee&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/438595"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=438595"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/438595\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=438595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=438595"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=438595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}