{"id":78926,"date":"2026-02-28T16:25:12","date_gmt":"2026-02-28T08:25:12","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/78926.html"},"modified":"2026-02-28T16:25:12","modified_gmt":"2026-02-28T08:25:12","slug":"%e7%a4%be%e4%ba%a4-app-%e5%ae%9e%e6%97%b6%e6%b6%88%e6%81%af%e7%b3%bb%e7%bb%9f%ef%bc%9awebsocket-%e9%9b%86%e6%88%90-redis-%e5%ae%9e%e7%8e%b0%e4%b8%87%e7%ba%a7%e5%b9%b6%e5%8f%91%e9%80%9a%e4%bf%a1","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/78926.html","title":{"rendered":"\u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf\uff1aWebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1"},"content":{"rendered":"<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>&#x1f3af; \u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf&#xff1a;WebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>&#x1f517;\u26a1 \u7269\u7406\u8fde\u63a5\u7684\u827a\u672f&#xff1a;WebSocket \u72b6\u6001\u7ba1\u7406\u4e0e\u5fc3\u8df3\u5185\u6838<\/li>\n<li>\n<ul>\n<li>1.1 \u5206\u5e03\u5f0f\u73af\u5883\u4e0b\u7684\u201c\u5bfb\u4eba\u542f\u4e8b\u201d\u95ee\u9898<\/li>\n<li>1.2 \u5fc3\u8df3\u5305&#xff1a;\u4e0d\u4ec5\u662f\u4e3a\u4e86\u4fdd\u6d3b&#xff0c;\u66f4\u662f\u4e3a\u4e86\u201c\u6740\u4eba\u201d<\/li>\n<li>&#x1f4bb;&#x1f680; \u4ee3\u7801\u5757 1&#xff1a;\u57fa\u4e8e Spring Boot \u7684 WebSocket \u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406<\/li>\n<\/ul>\n<\/li>\n<li>&#x1f504;&#x1f4e1; \u6d88\u606f\u4e2d\u67a2&#xff1a;Redis Pub\/Sub \u5982\u4f55\u5145\u5f53\u201c\u5206\u5e03\u5f0f\u603b\u7ebf\u201d&#xff1f;<\/li>\n<li>\n<ul>\n<li>2.1 \u6247\u51fa&#xff08;Fan-out&#xff09;\u4e0e\u8ba2\u9605\u6a21\u578b<\/li>\n<li>2.2 \u6d88\u606f\u6d41\u7684\u65f6\u5e8f\u56fe\u6a21\u578b<\/li>\n<\/ul>\n<\/li>\n<li>&#x1f4be;&#x1f4e6; \u6d88\u606f\u6301\u4e45\u5316&#xff1a;\u8bfb\u5199\u5206\u79bb\u4e0e\u201c\u6536\u4ef6\u7bb1\u201d\u5efa\u6a21\u903b\u8f91<\/li>\n<li>\n<ul>\n<li>3.1 \u5f02\u6b65\u5199\u5165&#xff08;Write-Behind&#xff09;\u7b56\u7565<\/li>\n<li>3.2 \u8bfb\u5199\u5206\u79bb\u7684\u201c\u62c9\u53d6\u6a21\u578b\u201d<\/li>\n<li>&#x1f4bb;&#x1f680; \u4ee3\u7801\u5757 2&#xff1a;Redis \u6d88\u606f\u5206\u53d1\u4e0e\u5f02\u6b65\u843d\u5e93\u5b9e\u73b0<\/li>\n<\/ul>\n<\/li>\n<li>&#x1f680;&#x1f3d9;\ufe0f \u6848\u4f8b\u590d\u76d8&#xff1a;10 \u4e07\u5e76\u53d1\u8fde\u63a5\u4e0b\u7684\u6027\u80fd\u538b\u69a8<\/li>\n<li>\n<ul>\n<li>4.1 \u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u8c03\u4f18&#xff08;Linux&#xff09;<\/li>\n<li>4.2 \u5185\u5b58\u5e03\u5c40\u4f18\u5316<\/li>\n<li>4.3 \u8d1f\u8f7d\u5747\u8861\u7684\u201c\u7c98\u6027\u201d\u535a\u5f08<\/li>\n<\/ul>\n<\/li>\n<li>\u26a0\ufe0f&#x1f4c9; \u907f\u5751\u6307\u5357&#xff1a;\u7ebf\u4e0a\u73af\u5883\u7684\u5341\u5927\u9677\u9631<\/li>\n<li>&#x1f31f; \u603b\u7ed3&#xff1a;\u6784\u5efa\u7a33\u5065 IM \u7cfb\u7edf\u7684\u5e95\u5c42\u903b\u8f91<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>&#x1f3af; \u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf&#xff1a;WebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1<\/h2>\n<p>\u524d\u8a00&#xff1a;\u5b9e\u65f6\u6027\u662f\u793e\u4ea4\u4ea7\u54c1\u7684\u547d\u8109<\/p>\n<p>\u60f3\u8c61\u4e00\u4e0b&#xff0c;\u4f60\u5728\u5fae\u4fe1\u4e0a\u53d1\u4e86\u4e00\u53e5\u201c\u5728\u5417&#xff1f;\u201d&#xff0c;\u7ed3\u679c\u5bf9\u65b9\u4e09\u5206\u949f\u540e\u624d\u6536\u5230&#xff0c;\u8fd9\u79cd\u4f53\u9a8c\u8db3\u4ee5\u8ba9\u4efb\u4f55\u793e\u4ea4\u4ea7\u54c1\u77ac\u95f4\u5173\u95e8\u3002IM \u7cfb\u7edf\u7684\u6838\u5fc3\u53ea\u6709\u56db\u4e2a\u5b57&#xff1a;\u6781\u901f\u3001\u53ef\u9760\u3002<\/p>\n<p>\u5f88\u591a\u5f00\u53d1\u8005\u5728\u505a\u5373\u65f6\u901a\u8baf\u65f6&#xff0c;\u7b2c\u4e00\u53cd\u5e94\u662f&#xff1a;\u201c\u6211\u6709 WebSocket \u534f\u8bae&#xff0c;\u8fde\u4e0a\u4e0d\u5c31\u884c\u4e86&#xff1f;\u201d\u3002\u4f46\u5728\u771f\u5b9e\u7684\u5de5\u7a0b\u73af\u5883\u4e0b&#xff0c;\u5f53\u4f60\u7684\u7528\u6237\u4ece 100 \u53d8\u6210 10 \u4e07&#xff0c;\u4f60\u4f1a\u53d1\u73b0\u539f\u6765\u7684\u201c\u8fde\u4e0a\u5c31\u884c\u201d\u4f1a\u6f14\u53d8\u6210\u5404\u79cd\u5669\u68a6&#xff1a;\u670d\u52a1\u5668\u5185\u5b58\u88ab\u957f\u8fde\u63a5\u6491\u7206\u3001\u7528\u6237\u8de8\u670d\u52a1\u5668\u767b\u5f55\u5bfc\u81f4\u6d88\u606f\u53d1\u4e22\u3001\u6570\u636e\u5e93\u5728\u6d77\u91cf\u6d88\u606f\u5199\u5165\u4e0b\u77ac\u95f4\u762b\u75ea\u3002<\/p>\n<p>\u4eca\u5929&#xff0c;\u6211\u4eec\u4e0d\u804a\u90a3\u4e9b\u6559\u79d1\u4e66\u4e0a\u7684\u63e1\u624b\u534f\u8bae&#xff0c;\u76f4\u63a5\u5207\u5165\u751f\u4ea7\u73af\u5883\u7684\u5b9e\u6218\u903b\u8f91&#xff1a;\u5982\u4f55\u7ba1\u7406\u5206\u5e03\u5f0f\u8fde\u63a5&#xff1f;Redis \u600e\u4e48\u505a\u6d88\u606f\u4e2d\u8f6c&#xff1f;\u6d88\u606f\u600e\u4e48\u5b58\u624d\u80fd\u6297\u4f4f\u77ac\u95f4\u7206\u53d1\u7684\u8bfb\u5199&#xff1f;<\/p>\n<hr \/>\n<h4>&#x1f517;\u26a1 \u7269\u7406\u8fde\u63a5\u7684\u827a\u672f&#xff1a;WebSocket \u72b6\u6001\u7ba1\u7406\u4e0e\u5fc3\u8df3\u5185\u6838<\/h4>\n<p>WebSocket \u6700\u5927\u7684\u9b45\u529b\u5728\u4e8e\u5176\u5168\u53cc\u5de5\u901a\u8baf&#xff0c;\u4f46\u5b83\u6700\u8ba9\u67b6\u6784\u5e08\u5934\u75bc\u7684\u5219\u662f\u5176**\u201c\u6709\u72b6\u6001\u6027\u201d**\u3002<\/p>\n<p>\u5728\u4f20\u7edf\u7684 REST API \u573a\u666f\u4e0b&#xff0c;\u670d\u52a1\u5668\u662f\u201c\u62d4\u6389\u65e0\u60c5\u201d\u7684&#xff0c;\u5904\u7406\u5b8c\u8bf7\u6c42\u5c31\u91ca\u653e\u8d44\u6e90\u3002\u4f46 WebSocket \u8981\u6c42\u670d\u52a1\u5668\u5fc5\u987b\u5728\u5185\u5b58\u91cc\u6b7b\u6b7b\u6390\u4f4f\u8fd9\u4e2a Socket \u8fde\u63a5\u3002\u5982\u679c\u4e00\u4e2a\u8fde\u63a5\u5360\u7528 10KB \u5185\u5b58&#xff0c;10 \u4e07\u5e76\u53d1\u5c31\u662f 1GB \u7684\u7eaf\u5185\u5b58\u5f00\u9500\u3002<\/p>\n<h5>1.1 \u5206\u5e03\u5f0f\u73af\u5883\u4e0b\u7684\u201c\u5bfb\u4eba\u542f\u4e8b\u201d\u95ee\u9898<\/h5>\n<p>\u5728\u591a\u673a\u623f\u3001\u591a\u8282\u70b9\u90e8\u7f72\u65f6&#xff0c;\u7528\u6237 A \u8fde\u5728 Server-1&#xff0c;\u7528\u6237 B \u8fde\u5728 Server-2\u3002\u5f53 A \u60f3\u7ed9 B \u53d1\u6d88\u606f\u65f6&#xff0c;Server-1 \u6839\u672c\u4e0d\u77e5\u9053 B \u7684 Socket \u5728\u54ea\u3002<\/p>\n<ul>\n<li>\u7269\u7406\u8def\u5f84&#xff1a;\u6211\u4eec\u9700\u8981\u5728 Redis \u91cc\u7ef4\u62a4\u4e00\u5f20**\u201c\u8fde\u63a5\u4f4d\u7f6e\u6620\u5c04\u8868\u201d**\u3002Key \u4e3a User_ID&#xff0c;Value \u4e3a Server_IP\u3002<\/li>\n<li>\u8def\u7531\u903b\u8f91&#xff1a;Server-1 \u53d1\u73b0 B \u4e0d\u5728\u672c\u5730&#xff0c;\u5c31\u53bb Redis \u67e5\u5230 B \u5728 Server-2&#xff0c;\u7136\u540e\u901a\u8fc7 Redis \u7684 Pub\/Sub&#xff08;\u53d1\u5e03\u8ba2\u9605&#xff09;\u6216\u8005\u6d88\u606f\u961f\u5217\u5c06\u6307\u4ee4\u7269\u7406\u8f6c\u53d1\u7ed9 Server-2\u3002<\/li>\n<\/ul>\n<h5>1.2 \u5fc3\u8df3\u5305&#xff1a;\u4e0d\u4ec5\u662f\u4e3a\u4e86\u4fdd\u6d3b&#xff0c;\u66f4\u662f\u4e3a\u4e86\u201c\u6740\u4eba\u201d<\/h5>\n<p>\u7f51\u7edc\u73af\u5883\u6781\u5176\u590d\u6742&#xff0c;\u79fb\u52a8\u7aef\u8fdb\u7535\u68af\u3001\u6362 Wi-Fi \u90fd\u4f1a\u5bfc\u81f4\u8fde\u63a5\u5047\u6b7b\u3002<\/p>\n<ul>\n<li>\u7269\u7406\u672c\u8d28&#xff1a;\u5fc3\u8df3\u5305&#xff08;Ping\/Pong&#xff09;\u7684\u4f5c\u7528\u4e0d\u662f\u544a\u8bc9\u670d\u52a1\u5668\u201c\u6211\u8fd8\u6d3b\u7740\u201d&#xff0c;\u800c\u662f\u8ba9\u670d\u52a1\u5668\u6709\u501f\u53e3\u6740\u6389\u90a3\u4e9b\u201c\u5df2\u7ecf\u8111\u6b7b\u201d\u7684\u50f5\u5c38\u8fde\u63a5&#xff0c;\u4ece\u800c\u91ca\u653e\u5b9d\u8d35\u7684\u5185\u6838\u6587\u4ef6\u53e5\u67c4&#xff08;File Descriptor&#xff09;\u3002<\/li>\n<li>\u5de5\u4e1a\u51c6\u5219&#xff1a;\u5728 Spring Boot \u4e2d&#xff0c;\u5efa\u8bae\u914d\u5408 Netty \u6846\u67b6\u5904\u7406\u8fd9\u4e9b\u5e95\u5c42\u7ec6\u8282&#xff0c;\u56e0\u4e3a\u5b83\u5bf9\u96f6\u62f7\u8d1d&#xff08;Zero-Copy&#xff09;\u7684\u652f\u6301\u80fd\u663e\u8457\u964d\u4f4e\u9ad8\u5e76\u53d1\u4e0b\u7684 CPU \u635f\u8017\u3002<\/li>\n<\/ul>\n<h5>&#x1f4bb;&#x1f680; \u4ee3\u7801\u5757 1&#xff1a;\u57fa\u4e8e Spring Boot \u7684 WebSocket \u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406<\/h5>\n<p><span class=\"token comment\">\/* &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n   \u4ee3\u7801\u5757 1&#xff1a;WebSocket \u8fde\u63a5\u7ba1\u7406\u6838\u5fc3\u903b\u8f91<br \/>\n   \u903b\u8f91&#xff1a;\u5904\u7406\u63e1\u624b\u9a8c\u8bc1\u3001Session \u7ed1\u5b9a\u4ee5\u53ca\u5206\u5e03\u5f0f\u4f4d\u7f6e\u4e0a\u62a5<br \/>\n   &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; *\/<\/span><br \/>\n<span class=\"token annotation punctuation\">&#064;Component<\/span><br \/>\n<span class=\"token annotation punctuation\">&#064;Slf4j<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">ChatWebSocketHandler<\/span> <span class=\"token keyword\">extends<\/span> <span class=\"token class-name\">TextWebSocketHandler<\/span> <span class=\"token punctuation\">{<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u672c\u5730 Session \u7f13\u5b58&#xff0c;\u7528\u4e8e\u5b58\u50a8\u5f53\u524d\u670d\u52a1\u5668\u627f\u8f7d\u7684\u8fde\u63a5<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token keyword\">static<\/span> <span class=\"token keyword\">final<\/span> <span class=\"token class-name\">Map<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">String<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">WebSocketSession<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> LOCAL_SESSIONS <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">ConcurrentHashMap<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">RedisTemplate<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">String<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">String<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> redisTemplate<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/**<br \/>\n     * \u7269\u7406\u8fde\u63a5\u5efa\u7acb\u6210\u529f&#xff1a;\u4e0a\u62a5\u4f4d\u7f6e\u5230 Redis<br \/>\n     *\/<\/span><br \/>\n    <span class=\"token annotation punctuation\">&#064;Override<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">afterConnectionEstablished<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">WebSocketSession<\/span> session<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token class-name\">String<\/span> userId <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">getUserId<\/span><span class=\"token punctuation\">(<\/span>session<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token class-name\">String<\/span> serverIp <span class=\"token operator\">&#061;<\/span> <span class=\"token class-name\">InetAddress<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getLocalHost<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getHostAddress<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ 1. \u672c\u5730\u5b58\u50a8&#xff0c;\u65b9\u4fbf\u76f4\u63a5\u63a8\u9001<\/span><br \/>\n        LOCAL_SESSIONS<span class=\"token punctuation\">.<\/span><span class=\"token function\">put<\/span><span class=\"token punctuation\">(<\/span>userId<span class=\"token punctuation\">,<\/span> session<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ 2. \u5206\u5e03\u5f0f\u8def\u7531\u4e0a\u62a5&#xff1a;User -&gt; ServerIp<\/span><br \/>\n        redisTemplate<span class=\"token punctuation\">.<\/span><span class=\"token function\">opsForValue<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">set<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;IM:ROUTE:&#034;<\/span> <span class=\"token operator\">&#043;<\/span> userId<span class=\"token punctuation\">,<\/span> serverIp<span class=\"token punctuation\">,<\/span> <span class=\"token number\">30<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">TimeUnit<\/span><span class=\"token punctuation\">.<\/span>MINUTES<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        log<span class=\"token punctuation\">.<\/span><span class=\"token function\">info<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;&#x1f680; \u7528\u6237 {} \u7269\u7406\u8fde\u63a5\u5efa\u7acb\u6210\u529f&#xff0c;\u5f52\u5c5e\u670d\u52a1\u5668&#xff1a;{}&#034;<\/span><span class=\"token punctuation\">,<\/span> userId<span class=\"token punctuation\">,<\/span> serverIp<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/**<br \/>\n     * \u7269\u7406\u8fde\u63a5\u65ad\u5f00&#xff1a;\u6e05\u7406 Redis \u72b6\u6001&#xff0c;\u9632\u6b62\u6d88\u606f\u8def\u7531\u5230\u7a7a\u5730\u5740<br \/>\n     *\/<\/span><br \/>\n    <span class=\"token annotation punctuation\">&#064;Override<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">afterConnectionClosed<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">WebSocketSession<\/span> session<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">CloseStatus<\/span> status<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token class-name\">String<\/span> userId <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">getUserId<\/span><span class=\"token punctuation\">(<\/span>session<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        LOCAL_SESSIONS<span class=\"token punctuation\">.<\/span><span class=\"token function\">remove<\/span><span class=\"token punctuation\">(<\/span>userId<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        redisTemplate<span class=\"token punctuation\">.<\/span><span class=\"token function\">delete<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;IM:ROUTE:&#034;<\/span> <span class=\"token operator\">&#043;<\/span> userId<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        log<span class=\"token punctuation\">.<\/span><span class=\"token function\">warn<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;&#x1f41a; \u7528\u6237 {} \u7269\u7406\u8fde\u63a5\u65ad\u5f00&#xff0c;\u5df2\u4ece\u5168\u5c40\u8def\u7531\u8868\u5254\u9664&#034;<\/span><span class=\"token punctuation\">,<\/span> userId<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">String<\/span> <span class=\"token function\">getUserId<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">WebSocketSession<\/span> session<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span><span class=\"token punctuation\">)<\/span> session<span class=\"token punctuation\">.<\/span><span class=\"token function\">getAttributes<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">get<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;uid&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<hr \/>\n<h4>&#x1f504;&#x1f4e1; \u6d88\u606f\u4e2d\u67a2&#xff1a;Redis Pub\/Sub \u5982\u4f55\u5145\u5f53\u201c\u5206\u5e03\u5f0f\u603b\u7ebf\u201d&#xff1f;<\/h4>\n<p>\u5728\u89e3\u51b3\u4e86\u201c\u7528\u6237\u5728\u54ea\u201d\u7684\u95ee\u9898\u540e&#xff0c;\u4e0b\u4e00\u6b65\u5c31\u662f\u6d88\u606f\u7684\u7269\u7406\u6295\u9012\u3002<\/p>\n<h5>2.1 \u6247\u51fa&#xff08;Fan-out&#xff09;\u4e0e\u8ba2\u9605\u6a21\u578b<\/h5>\n<p>\u5f53 User-A \u53d1\u9001\u6d88\u606f\u65f6&#xff0c;\u6d41\u7a0b\u5982\u4e0b&#xff1a;<\/p>\n<li>\u5224\u5b9a&#xff1a;Server-1 \u68c0\u67e5\u672c\u5730\u662f\u5426\u6709 User-B\u3002<\/li>\n<li>\u547d\u4e2d&#xff1a;\u5982\u679c\u6709&#xff0c;\u76f4\u63a5\u5199 Socket\u3002<\/li>\n<li>\u672a\u547d\u4e2d&#xff1a;Server-1 \u5c06\u6d88\u606f\u4e22\u5165 Redis Channel IM_MESSAGE_BUS\u3002<\/li>\n<li>\u5e7f\u64ad&#xff1a;\u96c6\u7fa4\u5185\u6240\u6709\u670d\u52a1\u5668\u90fd\u5728\u76d1\u542c\u8fd9\u4e2a Channel\u3002Server-2 \u6536\u5230\u540e&#xff0c;\u770b\u4e00\u773c&#xff1a;\u201c\u563f&#xff0c;B \u679c\u7136\u5728\u6211\u8fd9\u201d&#xff0c;\u7136\u540e\u6267\u884c\u672c\u5730 Socket \u5199\u5165\u3002<\/li>\n<h5>2.2 \u6d88\u606f\u6d41\u7684\u65f6\u5e8f\u56fe\u6a21\u578b<\/h5>\n<p>     \u7528\u6237 B (Client)<\/p>\n<p>     Server 2 (WebSocket)<\/p>\n<p>     Redis (Route &amp; Bus)<\/p>\n<p>     Server 1 (WebSocket)<\/p>\n<p>     \u7528\u6237 A (Client)<\/p>\n<p>      \u7528\u6237 B (Client)<\/p>\n<p>      Server 2 (WebSocket)<\/p>\n<p>      Redis (Route &amp; Bus)<\/p>\n<p>      Server 1 (WebSocket)<\/p>\n<p>      \u7528\u6237 A (Client)<\/p>\n<p>  #mermaid-svg-votArvyyHsbWLmt2{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-votArvyyHsbWLmt2 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-votArvyyHsbWLmt2 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-votArvyyHsbWLmt2 .error-icon{fill:#552222;}#mermaid-svg-votArvyyHsbWLmt2 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-votArvyyHsbWLmt2 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-votArvyyHsbWLmt2 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-votArvyyHsbWLmt2 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-votArvyyHsbWLmt2 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-votArvyyHsbWLmt2 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-votArvyyHsbWLmt2 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-votArvyyHsbWLmt2 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-votArvyyHsbWLmt2 .marker.cross{stroke:#333333;}#mermaid-svg-votArvyyHsbWLmt2 svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-votArvyyHsbWLmt2 p{margin:0;}#mermaid-svg-votArvyyHsbWLmt2 .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-votArvyyHsbWLmt2 text.actor&gt;tspan{fill:black;stroke:none;}#mermaid-svg-votArvyyHsbWLmt2 .actor-line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-votArvyyHsbWLmt2 .innerArc{stroke-width:1.5;stroke-dasharray:none;}#mermaid-svg-votArvyyHsbWLmt2 .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg-votArvyyHsbWLmt2 .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg-votArvyyHsbWLmt2 #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg-votArvyyHsbWLmt2 .sequenceNumber{fill:white;}#mermaid-svg-votArvyyHsbWLmt2 #sequencenumber{fill:#333;}#mermaid-svg-votArvyyHsbWLmt2 #crosshead path{fill:#333;stroke:#333;}#mermaid-svg-votArvyyHsbWLmt2 .messageText{fill:#333;stroke:none;}#mermaid-svg-votArvyyHsbWLmt2 .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-votArvyyHsbWLmt2 .labelText,#mermaid-svg-votArvyyHsbWLmt2 .labelText&gt;tspan{fill:black;stroke:none;}#mermaid-svg-votArvyyHsbWLmt2 .loopText,#mermaid-svg-votArvyyHsbWLmt2 .loopText&gt;tspan{fill:black;stroke:none;}#mermaid-svg-votArvyyHsbWLmt2 .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-votArvyyHsbWLmt2 .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-votArvyyHsbWLmt2 .noteText,#mermaid-svg-votArvyyHsbWLmt2 .noteText&gt;tspan{fill:black;stroke:none;}#mermaid-svg-votArvyyHsbWLmt2 .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg-votArvyyHsbWLmt2 .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg-votArvyyHsbWLmt2 .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg-votArvyyHsbWLmt2 .actorPopupMenu{position:absolute;}#mermaid-svg-votArvyyHsbWLmt2 .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 \/ 0.4));}#mermaid-svg-votArvyyHsbWLmt2 .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-votArvyyHsbWLmt2 .actor-man circle,#mermaid-svg-votArvyyHsbWLmt2 line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg-votArvyyHsbWLmt2 :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<\/p>\n<p>   \u53d1\u9001\u6d88\u606f {to:B, msg:&#034;Hello&#034;}<\/p>\n<p>   \u67e5\u8be2 B \u7684\u4f4d\u7f6e<\/p>\n<p>   \u8fd4\u56de B \u5728 Server 2<\/p>\n<p>   PUBLISH \u6d88\u606f\u5230 IM_BUS<\/p>\n<p>   \u5e7f\u64ad\u6d88\u606f<\/p>\n<p>   \u68c0\u67e5\u672c\u5730 Session \u7f13\u5b58<\/p>\n<p>   \u5199\u5165 Socket<\/p>\n<hr \/>\n<h4>&#x1f4be;&#x1f4e6; \u6d88\u606f\u6301\u4e45\u5316&#xff1a;\u8bfb\u5199\u5206\u79bb\u4e0e\u201c\u6536\u4ef6\u7bb1\u201d\u5efa\u6a21\u903b\u8f91<\/h4>\n<p>\u5343\u4e07\u4e0d\u8981\u5728 WebSocket \u7ebf\u7a0b\u91cc\u540c\u6b65\u5199\u6570\u636e\u5e93&#xff01; \u5982\u679c\u4f60\u7684\u6d88\u606f\u843d\u5e93\u9700\u8981 50ms&#xff0c;1 \u4e07\u4e2a\u5e76\u53d1\u8bf7\u6c42\u5c31\u4f1a\u77ac\u95f4\u62d6\u57ae\u4f60\u7684 I\/O \u7ebf\u7a0b\u6c60\u3002<\/p>\n<h5>3.1 \u5f02\u6b65\u5199\u5165&#xff08;Write-Behind&#xff09;\u7b56\u7565<\/h5>\n<ul>\n<li>\u7269\u7406\u7f13\u5b58&#xff1a;\u6d88\u606f\u5230\u8fbe\u670d\u52a1\u5668\u540e&#xff0c;\u5148\u5b58\u5165 Redis \u7684 List \u6216 Stream \u7ed3\u6784\u3002<\/li>\n<li>\u5f02\u6b65\u843d\u5e93&#xff1a;\u7531\u4e13\u95e8\u7684\u6301\u4e45\u5316\u7ebf\u7a0b\u6c60&#xff08;\u6216\u901a\u8fc7 Kafka \u8f6c\u53d1&#xff09;\u6279\u91cf\u5c06\u6d88\u606f\u5199\u5165 MySQL\u3002\u8fd9\u6837\u5373\u4f7f\u6570\u636e\u5e93\u77ac\u95f4\u538b\u529b\u5927&#xff0c;\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u7528\u6237\u7684\u804a\u5929\u4f53\u9a8c\u3002<\/li>\n<\/ul>\n<h5>3.2 \u8bfb\u5199\u5206\u79bb\u7684\u201c\u62c9\u53d6\u6a21\u578b\u201d<\/h5>\n<p>\u4e3a\u4e86\u5e94\u5bf9\u7fa4\u804a\u8fd9\u79cd\u201c\u4e00\u4eba\u53d1&#xff0c;\u4e07\u4eba\u6536\u201d\u7684\u7206\u53d1\u6027\u8bfb\u8bf7\u6c42&#xff0c;\u6211\u4eec\u901a\u5e38\u91c7\u7528 \u201c\u8bfb\u6269\u6563&#xff08;Pull Model&#xff09;\u201d\u3002<\/p>\n<ul>\n<li>\u5199\u64cd\u4f5c&#xff1a;\u6d88\u606f\u53ea\u5728\u53d1\u4ef6\u4eba\u7684\u201c\u53d1\u4ef6\u7bb1\u201d\u5b58\u4e00\u4efd\u3002<\/li>\n<li>\u8bfb\u64cd\u4f5c&#xff1a;\u6536\u4ef6\u4eba\u4e0a\u7ebf\u65f6&#xff0c;\u62c9\u53d6\u5bf9\u5e94\u53d1\u4ef6\u4eba\u7684\u589e\u91cf\u6570\u636e\u3002\u8fd9\u6781\u5927\u51cf\u5c11\u4e86\u6d88\u606f\u5b58\u50a8\u7684\u5197\u4f59\u3002<\/li>\n<\/ul>\n<h5>&#x1f4bb;&#x1f680; \u4ee3\u7801\u5757 2&#xff1a;Redis \u6d88\u606f\u5206\u53d1\u4e0e\u5f02\u6b65\u843d\u5e93\u5b9e\u73b0<\/h5>\n<p><span class=\"token comment\">\/* &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n   \u4ee3\u7801\u5757 2&#xff1a;\u57fa\u4e8e Redis \u8ba2\u9605\u7684\u6d88\u606f\u4e2d\u8f6c\u4e2d\u5fc3<br \/>\n   \u7269\u7406\u7279\u6027&#xff1a;\u652f\u6301\u591a\u8282\u70b9\u6d88\u606f\u4e92\u901a&#xff0c;\u4e1a\u52a1\u903b\u8f91\u5f02\u6b65\u89e3\u8026<br \/>\n   &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; *\/<\/span><br \/>\n<span class=\"token annotation punctuation\">&#064;Service<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">MessageBusListener<\/span> <span class=\"token punctuation\">{<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">ChatWebSocketHandler<\/span> handler<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">MessageRepository<\/span> messageRepository<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ JPA \u6301\u4e45\u5316<\/span><\/p>\n<p>    <span class=\"token comment\">\/**<br \/>\n     * Redis \u76d1\u542c\u5668&#xff1a;\u5904\u7406\u8de8\u670d\u52a1\u5668\u4f20\u6765\u7684\u6d88\u606f<br \/>\n     *\/<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">onReceive<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">ChatMessage<\/span> chatMsg<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\">\/\/ 1. \u5c1d\u8bd5\u672c\u5730\u63a8\u9001&#xff08;\u5982\u679c\u7528\u6237\u5728\u5f53\u524d\u8282\u70b9&#xff09;<\/span><br \/>\n        <span class=\"token keyword\">boolean<\/span> pushSuccess <span class=\"token operator\">&#061;<\/span> handler<span class=\"token punctuation\">.<\/span><span class=\"token function\">pushToLocal<\/span><span class=\"token punctuation\">(<\/span>chatMsg<span class=\"token punctuation\">.<\/span><span class=\"token function\">getToId<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> chatMsg<span class=\"token punctuation\">.<\/span><span class=\"token function\">getContent<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ 2. \u65e0\u8bba\u662f\u5426\u63a8\u9001\u6210\u529f&#xff0c;\u8fdb\u5165\u5f02\u6b65\u6301\u4e45\u5316\u961f\u5217<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u7269\u7406\u672c\u8d28&#xff1a;\u5229\u7528\u72ec\u7acb\u7ebf\u7a0b\u6c60\u6267\u884c\u78c1\u76d8 I\/O&#xff0c;\u4e0d\u963b\u585e\u6d88\u606f\u8f6c\u53d1<\/span><br \/>\n        <span class=\"token class-name\">CompletableFuture<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">runAsync<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">-&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            messageRepository<span class=\"token punctuation\">.<\/span><span class=\"token function\">save<\/span><span class=\"token punctuation\">(<\/span>chatMsg<span class=\"token punctuation\">.<\/span><span class=\"token function\">toEntity<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>pushSuccess<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            log<span class=\"token punctuation\">.<\/span><span class=\"token function\">debug<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;&#x1f3af; \u8de8\u8282\u70b9\u6d88\u606f\u5b9e\u65f6\u6295\u9012\u6210\u529f: {}&#034;<\/span><span class=\"token punctuation\">,<\/span> chatMsg<span class=\"token punctuation\">.<\/span><span class=\"token function\">getMsgId<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<hr \/>\n<h4>&#x1f680;&#x1f3d9;\ufe0f \u6848\u4f8b\u590d\u76d8&#xff1a;10 \u4e07\u5e76\u53d1\u8fde\u63a5\u4e0b\u7684\u6027\u80fd\u538b\u69a8<\/h4>\n<p>\u5f53\u8fde\u63a5\u6570\u7a81\u7834 10 \u4e07\u5927\u5173\u65f6&#xff0c;\u771f\u6b63\u7684\u74f6\u9888\u5f80\u5f80\u5728\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u7684\u7f51\u7edc\u534f\u8bae\u6808\u3002<\/p>\n<h5>4.1 \u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u8c03\u4f18&#xff08;Linux&#xff09;<\/h5>\n<p>\u5982\u679c\u4e0d\u8c03\u4f18&#xff0c;\u4f60\u7684\u670d\u52a1\u5668\u5373\u4fbf\u5185\u5b58\u518d\u5927&#xff0c;\u4e5f\u4f1a\u62a5 Too many open files\u3002<\/p>\n<ul>\n<li>\u7269\u7406\u8c03\u4f18&#xff1a;\u4fee\u6539 ulimit -n 655350\u3002<\/li>\n<li>\u5185\u6838\u53c2\u6570&#xff1a;\u8c03\u5927 net.ipv4.tcp_max_syn_backlog&#xff08;\u534a\u8fde\u63a5\u961f\u5217&#xff09;\u548c net.core.somaxconn&#xff0c;\u9632\u6b62\u7a81\u53d1\u63e1\u624b\u8bf7\u6c42\u88ab\u7cfb\u7edf\u76f4\u63a5\u4e22\u5f03\u3002<\/li>\n<\/ul>\n<h5>4.2 \u5185\u5b58\u5e03\u5c40\u4f18\u5316<\/h5>\n<p>\u5728 Java \u4e2d&#xff0c;\u9ed8\u8ba4\u7684\u7ebf\u7a0b\u6808\u7a7a\u95f4\u662f 1MB\u3002\u5982\u679c\u6bcf\u4e2a\u8fde\u63a5\u90fd\u5f00\u4e00\u4e2a\u7ebf\u7a0b&#xff0c;10 \u4e07\u4e2a\u8fde\u63a5\u5c31\u9700\u8981 100GB \u5185\u5b58&#xff0c;\u8fd9\u663e\u7136\u662f\u4e0d\u73b0\u5b9e\u7684\u3002<\/p>\n<ul>\n<li>\u5bf9\u7b56&#xff1a;\u4f7f\u7528 Netty (NIO)\u3002Netty \u901a\u8fc7\u4e8b\u4ef6\u5faa\u73af\u673a\u5236&#xff0c;\u7528\u5c11\u91cf\u7684\u7ebf\u7a0b\u5904\u7406\u6d77\u91cf\u7684\u8fde\u63a5\u3002\u6bcf\u4e00\u4e2a\u8fde\u63a5\u5728\u5185\u5b58\u4e2d\u4ec5\u8868\u73b0\u4e3a\u4e00\u4e2a Channel \u5bf9\u8c61&#xff0c;\u5927\u5927\u964d\u4f4e\u4e86\u5185\u5b58\u5bc6\u5ea6\u3002<\/li>\n<\/ul>\n<h5>4.3 \u8d1f\u8f7d\u5747\u8861\u7684\u201c\u7c98\u6027\u201d\u535a\u5f08<\/h5>\n<p>\u4f7f\u7528 Nginx \u8d1f\u8f7d\u5747\u8861\u65f6&#xff0c;\u5fc5\u987b\u5f00\u542f ip_hash \u6216 sticky \u6a21\u5f0f\u3002<\/p>\n<ul>\n<li>\u7269\u7406\u539f\u56e0&#xff1a;WebSocket \u63e1\u624b\u662f\u4ece HTTP \u5f00\u59cb\u7684\u3002\u5982\u679c\u7b2c\u4e00\u6b21\u63e1\u624b\u5728 S1&#xff0c;\u7b2c\u4e8c\u6b21\u5728 S2&#xff0c;\u8fde\u63a5\u5c06\u6c38\u8fdc\u65e0\u6cd5\u5efa\u7acb\u3002\u6211\u4eec\u9700\u8981\u4fdd\u8bc1\u540c\u4e00\u4e2a\u7528\u6237\u7684\u63e1\u624b\u8bf7\u6c42\u7269\u7406\u843d\u5230\u540c\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u26a0\ufe0f&#x1f4c9; \u907f\u5751\u6307\u5357&#xff1a;\u7ebf\u4e0a\u73af\u5883\u7684\u5341\u5927\u9677\u9631<\/h4>\n<li>\u5ffd\u7565 Nginx \u8d85\u65f6&#xff1a;Nginx \u9ed8\u8ba4 60 \u79d2\u6ca1\u6d3b\u52a8\u4f1a\u7269\u7406\u65ad\u5f00\u8fde\u63a5\u3002\u4f60\u5fc5\u987b\u914d\u7f6e proxy_read_timeout \u5230 10 \u5206\u949f\u4ee5\u4e0a\u3002<\/li>\n<li>\u6ca1\u6709\u6d88\u606f\u5e8f\u5217\u53f7&#xff1a;\u5206\u5e03\u5f0f\u73af\u5883\u4e0b&#xff0c;\u6d88\u606f\u53ef\u80fd\u4e71\u5e8f\u3002\u5ba2\u6237\u7aef\u5fc5\u987b\u5e26\u4e0a\u81ea\u589e\u5e8f\u5217\u53f7&#xff0c;\u7531\u524d\u7aef\u91cd\u65b0\u6392\u5e8f\u3002<\/li>\n<li>Redis \u70ed\u70b9 Key&#xff1a;\u5982\u679c\u6240\u6709\u7fa4\u804a\u90fd\u6324\u5728\u4e00\u4e2a Redis Channel \u91cc&#xff0c;\u90a3\u4e2a Redis \u8282\u70b9\u4f1a\u56e0\u4e3a\u5355 CPU \u8fc7\u8f7d\u800c\u5d29\u6e83\u3002\n<ul>\n<li>\u5bf9\u7b56&#xff1a;\u6839\u636e\u7fa4 ID \u8fdb\u884c Hash \u5206\u7247&#xff0c;\u5206\u5e03\u5230\u4e0d\u540c\u7684 Redis \u8282\u70b9\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5ffd\u7565\u79bb\u7ebf\u8865\u53d1&#xff1a;\u7528\u6237\u8fdb\u7535\u68af\u65ad\u7f51\u4e86\u3002\n<ul>\n<li>\u5bf9\u7b56&#xff1a;\u5229\u7528 Redis ZSet \u5b58\u50a8\u6700\u8fd1 50 \u6761\u6d88\u606f\u3002\u7528\u6237\u91cd\u8fde\u540e&#xff0c;\u6839\u636e\u4e0a\u6b21\u6536\u5230\u7684\u6d88\u606f ID \u6267\u884c ZRANGEBYSCORE \u62c9\u53d6\u589e\u91cf\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u524d\u7aef\u91cd\u8fde\u98ce\u66b4&#xff1a;\u670d\u52a1\u91cd\u542f\u65f6&#xff0c;10 \u4e07\u4e2a\u5ba2\u6237\u7aef\u540c\u65f6\u91cd\u8fde\u3002\n<ul>\n<li>\u5bf9\u7b56&#xff1a;\u91cd\u8fde\u7b97\u6cd5\u589e\u52a0 Jitter&#xff08;\u968f\u673a\u6296\u52a8&#xff09; \u65f6\u95f4&#xff0c;\u628a\u538b\u529b\u5728 30 \u79d2\u5185\u7269\u7406\u6253\u6563\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5ffd\u7565\u6570\u636e\u8131\u654f&#xff1a;\u5728 WebSocket \u94fe\u8def\u4e0a\u4f20\u8f93\u660e\u6587\u5bc6\u7801\u6216\u7528\u6237\u654f\u611f ID\u3002<\/li>\n<li>\u5185\u5b58\u6cc4\u9732&#xff1a;\u5728 LOCAL_SESSIONS \u4e2d\u5b58\u4e86\u5bf9\u8c61&#xff0c;\u8fde\u63a5\u65ad\u5f00\u6ca1\u5220\u5e72\u51c0&#xff0c;\u8fd0\u884c\u4e00\u5468\u540e OOM\u3002<\/li>\n<li>\u5927\u6d88\u606f\u70b8\u5f39&#xff1a;\u7528\u6237\u53d1\u9001 10MB \u7684\u56fe\u7247\u3002\n<ul>\n<li>\u5bf9\u7b56&#xff1a;\u9650\u5236 MaxBinaryMessageBufferSize&#xff0c;\u56fe\u7247\/\u89c6\u9891\u8d70 OSS&#xff0c;WebSocket \u53ea\u4f20 URL\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u914d\u7f6e\u8fc7\u5c0f&#xff1a;\u6d88\u606f\u5f02\u6b65\u843d\u5e93\u65f6&#xff0c;\u7ebf\u7a0b\u6c60\u592a\u731b&#xff0c;\u628a\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u5360\u6ee1\u4e86&#xff0c;\u5bfc\u81f4\u6b63\u5e38\u7684 HTTP \u4e1a\u52a1\u4e5f\u5d29\u4e86\u3002<\/li>\n<li>\u7f3a\u4e4f\u5206\u7247&#xff08;Sharding&#xff09;\u610f\u8bc6&#xff1a;\u5355\u4e00 Redis \u5b58\u50a8\u5168\u91cf\u8def\u7531\u8868\u3002\u5728\u8d85\u5927\u89c4\u6a21\u573a\u666f\u4e0b&#xff0c;\u8bfb\u5199 Redis \u8def\u7531\u8868\u4e5f\u4f1a\u4ea7\u751f\u7269\u7406\u7ade\u4e89\u3002<\/li>\n<hr \/>\n<h4>&#x1f31f; \u603b\u7ed3&#xff1a;\u6784\u5efa\u7a33\u5065 IM \u7cfb\u7edf\u7684\u5e95\u5c42\u903b\u8f91<\/h4>\n<p>\u901a\u8fc7\u5bf9 WebSocket \u72b6\u6001\u7ba1\u7406\u3001Redis \u7269\u7406\u4e2d\u8f6c\u4ee5\u53ca\u5f02\u6b65\u6301\u4e45\u5316\u94fe\u8def\u7684\u6df1\u5ea6\u62c6\u89e3&#xff0c;\u6211\u4eec\u53ef\u4ee5\u6c89\u6dc0\u51fa\u4e09\u6761\u6838\u5fc3\u539f\u5219&#xff1a;<\/p>\n<li>\u8fde\u63a5\u5728\u672c\u5730&#xff0c;\u72b6\u6001\u5728\u5168\u5c40&#xff1a;\u5229\u7528 Redis \u62b9\u5e73\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u7269\u7406\u754c\u9650\u3002<\/li>\n<li>\u5199\u8981\u5feb&#xff0c;\u8bfb\u8981\u7f13&#xff1a;\u5229\u7528\u5f02\u6b65\u5316\u548c\u8bfb\u6269\u6563\u6a21\u578b&#xff0c;\u4fdd\u62a4\u6700\u8106\u5f31\u7684\u6570\u636e\u5e93\u3002<\/li>\n<li>\u656c\u754f\u7269\u7406\u6781\u9650&#xff1a;\u901a\u8fc7\u5185\u6838\u8c03\u4f18\u548c NIO \u6a21\u578b&#xff0c;\u5728\u6709\u9650\u7684\u786c\u4ef6\u8d44\u6e90\u91cc\u6362\u53d6\u6700\u9ad8\u7684\u5e76\u53d1\u5bc6\u5ea6\u3002<\/li>\n<p>\u611f\u609f&#xff1a;\u5728\u5373\u65f6\u901a\u8baf\u7684\u4e16\u754c\u91cc&#xff0c;\u6570\u636e\u6d41\u52a8\u7684\u6bcf\u4e00\u6beb\u79d2&#xff0c;\u90fd\u662f\u5bf9\u7cfb\u7edf\u8bbe\u8ba1\u4e25\u8c28\u6027\u7684\u7ec8\u6781\u5ba1\u5224\u3002\u638c\u63e1\u4e86\u201c\u8fde\u63a5\u3001\u4e2d\u8f6c\u3001\u5b58\u50a8\u201d\u8fd9\u4e09\u4e2a\u7269\u7406\u5185\u6838&#xff0c;\u4f60\u4fbf\u62e5\u6709\u4e86\u5728\u5343\u4e07\u7ea7\u6d41\u91cf\u6d2a\u6d41\u4e2d&#xff0c;\u7cbe\u51c6\u628a\u63a7\u6bcf\u4e00\u7b14\u4fe1\u606f\u8109\u52a8\u7684\u6700\u9ad8\u6743\u529b\u3002<\/p>\n<hr \/>\n<p>&#x1f525; \u89c9\u5f97\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u4f60\u6709\u542f\u53d1&#xff1f;\u522b\u5fd8\u4e86\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u5173\u6ce8\u652f\u6301\u4e00\u4e0b&#xff01; &#x1f4ac; \u4e92\u52a8\u8bdd\u9898&#xff1a;\u4f60\u5728\u505a\u5b9e\u65f6\u804a\u5929\u7cfb\u7edf\u65f6&#xff0c;\u9047\u5230\u8fc7\u6700\u8be1\u5f02\u7684\u6d88\u606f\u4e22\u5931\u6848\u4f8b\u662f\u4ec0\u4e48&#xff1f;\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u7559\u4e0b\u4f60\u7684\u586b\u5751\u7ecf\u5386&#xff0c;\u6211\u4eec\u4e00\u8d77\u62c6\u89e3&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u76ee\u5f55&#x1f3af; \u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf&#xff1a;WebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1&#x1f517;\u26a1 \u7269\u7406\u8fde\u63a5\u7684\u827a\u672f&#xff1a;WebSocket \u72b6\u6001\u7ba1\u7406\u4e0e\u5fc3\u8df3\u5185\u68381.1 \u5206\u5e03\u5f0f\u73af\u5883\u4e0b\u7684\u201c\u5bfb\u4eba\u542f\u4e8b\u201d\u95ee\u98981.2 \u5fc3\u8df3\u5305&#xff1a;\u4e0d\u4ec5\u662f\u4e3a\u4e86\u4fdd\u6d3b&#xff0c;\u66f4\u662f\u4e3a\u4e86\u201c\u6740\u4eba\u201d&#x1f4bb;&#x1f680; \u4ee3\u7801\u5757 1&#xff1a;\u57fa\u4e8e Spring Boot \u7684 WebSocket \u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406&#x1f504;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[8744,8745,8743,105,947,1862],"topic":[],"class_list":["post-78926","post","type-post","status-publish","format-standard","hentry","category-server","tag-app","tag-8745","tag-8743","tag-redis","tag-websocket","tag-wpf"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf\uff1aWebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/78926.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf\uff1aWebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u76ee\u5f55&#x1f3af; \u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf&#xff1a;WebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1&#x1f517;\u26a1 \u7269\u7406\u8fde\u63a5\u7684\u827a\u672f&#xff1a;WebSocket \u72b6\u6001\u7ba1\u7406\u4e0e\u5fc3\u8df3\u5185\u68381.1 \u5206\u5e03\u5f0f\u73af\u5883\u4e0b\u7684\u201c\u5bfb\u4eba\u542f\u4e8b\u201d\u95ee\u98981.2 \u5fc3\u8df3\u5305&#xff1a;\u4e0d\u4ec5\u662f\u4e3a\u4e86\u4fdd\u6d3b&#xff0c;\u66f4\u662f\u4e3a\u4e86\u201c\u6740\u4eba\u201d&#x1f4bb;&#x1f680; \u4ee3\u7801\u5757 1&#xff1a;\u57fa\u4e8e Spring Boot \u7684 WebSocket \u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406&#x1f504;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/78926.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-28T08:25:12+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/78926.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/78926.html\",\"name\":\"\u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf\uff1aWebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-28T08:25:12+00:00\",\"dateModified\":\"2026-02-28T08:25:12+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/78926.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/78926.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/78926.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf\uff1aWebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf\uff1aWebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/78926.html","og_locale":"zh_CN","og_type":"article","og_title":"\u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf\uff1aWebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u76ee\u5f55&#x1f3af; \u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf&#xff1a;WebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1&#x1f517;\u26a1 \u7269\u7406\u8fde\u63a5\u7684\u827a\u672f&#xff1a;WebSocket \u72b6\u6001\u7ba1\u7406\u4e0e\u5fc3\u8df3\u5185\u68381.1 \u5206\u5e03\u5f0f\u73af\u5883\u4e0b\u7684\u201c\u5bfb\u4eba\u542f\u4e8b\u201d\u95ee\u98981.2 \u5fc3\u8df3\u5305&#xff1a;\u4e0d\u4ec5\u662f\u4e3a\u4e86\u4fdd\u6d3b&#xff0c;\u66f4\u662f\u4e3a\u4e86\u201c\u6740\u4eba\u201d&#x1f4bb;&#x1f680; \u4ee3\u7801\u5757 1&#xff1a;\u57fa\u4e8e Spring Boot \u7684 WebSocket \u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406&#x1f504;","og_url":"https:\/\/www.wsisp.com\/helps\/78926.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-28T08:25:12+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/78926.html","url":"https:\/\/www.wsisp.com\/helps\/78926.html","name":"\u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf\uff1aWebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-28T08:25:12+00:00","dateModified":"2026-02-28T08:25:12+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/78926.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/78926.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/78926.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u793e\u4ea4 App \u5b9e\u65f6\u6d88\u606f\u7cfb\u7edf\uff1aWebSocket \u96c6\u6210 Redis \u5b9e\u73b0\u4e07\u7ea7\u5e76\u53d1\u901a\u4fe1"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/78926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=78926"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/78926\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=78926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=78926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=78926"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=78926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}