{"id":18189,"date":"2025-06-28T07:10:32","date_gmt":"2025-06-27T23:10:32","guid":{"rendered":"https:\/\/92it.top\/?p=18189"},"modified":"2025-06-28T07:11:57","modified_gmt":"2025-06-27T23:11:57","slug":"%e5%a4%a7%e7%99%bd%e8%af%9d-node-js-%e5%bc%82%e6%ad%a5%e5%ba%95%e5%b1%82%e5%ae%9e%e7%8e%b0%e5%8e%9f%e7%90%86","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=18189","title":{"rendered":"\u5927\u767d\u8bdd Node.js \u5f02\u6b65\u5e95\u5c42\u5b9e\u73b0\u539f\u7406"},"content":{"rendered":"\n<p><strong>\u524d\u8a00<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Node.js \u7684\u5f02\u6b65\u7279\u6027\u662f\u5176\u9ad8\u6027\u80fd\u7684\u6838\u5fc3\u4f18\u52bf\uff0c\u5176\u5e95\u5c42\u5b9e\u73b0\u878d\u5408\u4e86 JavaScript \u4e8b\u4ef6\u5faa\u73af\u673a\u5236\u3001Libuv \u5e93\u7684\u7ebf\u7a0b\u6c60\u7ba1\u7406\uff0c\u4ee5\u53ca\u64cd\u4f5c\u7cfb\u7edf\u7684\u5f02\u6b65 I\/O \u80fd\u529b\u3002\u4ee5\u4e0b\u901a\u8fc7\u5177\u4f53\u793a\u4f8b\u548c\u5e95\u5c42\u539f\u7406\u89e3\u6790\uff0c\u6df1\u5165\u7406\u89e3\u5176\u5de5\u4f5c\u673a\u5236\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"890\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-462-1024x890.png\" alt=\"\" class=\"wp-image-18191\" style=\"width:490px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-462-1024x890.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-462-300x261.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-462-768x667.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-462-1536x1335.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-462-830x721.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-462-230x200.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-462-350x304.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-462-480x417.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-462.png 1650w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>Node.js \u7684\u7ec4\u6210\u548c\u4ee3\u7801\u67b6\u6784<\/strong><\/p>\n\n\n\n<p>\u4e0b\u9762\u5148\u6765\u770b\u4e00\u4e0bNode.js \u7684\u7ec4\u6210\u3002Node.js \u4e3b\u8981\u662f\u7531 V8\u3001Libuv \u548c\u4e00\u4e9b\u7b2c\u4e09\u65b9\u5e93\u7ec4\u6210\u3002<\/p>\n\n\n\n<ul>\n<li>1. V8 \u6211\u4eec\u90fd\u6bd4\u8f83\u719f\u6089\uff0c\u5b83\u662f\u4e00\u4e2a JS \u5f15\u64ce\u3002\u4f46\u662f\u5b83\u4e0d\u4ec5\u5b9e\u73b0\u4e86 JS \u89e3\u6790\u548c\u6267\u884c\uff0c\u5b83\u8fd8\u662f\u81ea\u5b9a\u4e49\u62d3\u5c55\u3002\u6bd4\u5982\u8bf4\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 V8 \u63d0\u4f9b\u4e00\u4e9b C++ API \u53bb\u5b9a\u4e49\u4e00\u4e9b\u5168\u5c40\u53d8\u91cf\uff0c\u8fd9\u6837\u8bdd\u6211\u4eec\u5728 JS \u91cc\u9762\u53bb\u4f7f\u7528\u8fd9\u4e2a\u53d8\u91cf\u4e86\u3002\u6b63\u662f\u56e0\u4e3a V8 \u652f\u6301\u8fd9\u4e2a\u81ea\u5b9a\u4e49\u7684\u62d3\u5c55\uff0c\u6240\u4ee5\u624d\u6709\u4e86 Node.js \u7b49 JS \u8fd0\u884c\u65f6\u3002<\/li>\n\n\n\n<li>2. Libuv \u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u5f02\u6b65 IO \u5e93\u3002\u5b83\u4e3b\u8981\u7684\u529f\u80fd\u662f\u5b83\u5c01\u88c5\u4e86\u5404\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u7684\u4e00\u4e9b API\uff0c \u63d0\u4f9b\u7f51\u7edc\u8fd8\u6709\u6587\u4ef6\u8fdb\u7a0b\u7684\u8fd9\u4e9b\u529f\u80fd\u3002\u6211\u4eec\u77e5\u9053\u5728 JS \u91cc\u9762\u662f\u6ca1\u6709\u7f51\u7edc\u6587\u4ef6\u8fd9\u4e9b\u529f\u80fd\u7684\uff0c\u5728\u524d\u7aef\u65f6\uff0c\u662f\u7531\u6d4f\u89c8\u5668\u63d0\u4f9b\u7684\uff0c\u800c\u5728 Node.js \u91cc\uff0c\u8fd9\u4e9b\u529f\u80fd\u662f\u7531 Libuv \u63d0\u4f9b\u7684\u3002<\/li>\n\n\n\n<li>3. \u53e6\u5916 Node.js \u91cc\u9762\u8fd8\u5f15\u7528\u4e86\u5f88\u591a\u7b2c\u4e09\u65b9\u5e93\uff0c\u6bd4\u5982 DNS \u89e3\u6790\u5e93\uff0c\u8fd8\u6709 HTTP \u89e3\u6790\u5668\u7b49\u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u63a5\u4e0b\u6765\u770b\u4e00\u4e0b Node.js \u4ee3\u7801\u6574\u4f53\u7684\u67b6\u6784\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"638\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-463-1024x638.png\" alt=\"\" class=\"wp-image-18192\" style=\"width:478px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-463-1024x638.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-463-300x187.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-463-768x478.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-463-1536x956.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-463-830x517.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-463-230x143.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-463-350x218.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-463-480x299.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-463.png 1876w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>Node.js \u4ee3\u7801\u4e3b\u8981\u662f\u5206\u4e3a\u4e09\u4e2a\u90e8\u5206\uff0c\u5206\u522b\u662fC\u3001C++ \u548c JS\u3002<\/p>\n\n\n\n<ul>\n<li>1. JS \u4ee3\u7801\u5c31\u662f\u6211\u4eec\u5e73\u65f6\u5728\u4f7f\u7528\u7684\u90a3\u4e9b JS \u7684\u6a21\u5757\uff0c\u6bd4\u65b9\u8bf4\u50cf http \u548c fs \u8fd9\u4e9b\u6a21\u5757\u3002<\/li>\n\n\n\n<li>2. C++ \u4ee3\u7801\u4e3b\u8981\u5206\u4e3a\u4e09\u4e2a\u90e8\u5206\uff0c\u7b2c\u4e00\u90e8\u5206\u4e3b\u8981\u662f\u5c01\u88c5 Libuv \u548c\u7b2c\u4e09\u65b9\u5e93\u7684 C++ \u4ee3\u7801\uff0c\u6bd4\u5982net \u548c fs \u8fd9\u4e9b\u6a21\u5757\u90fd\u4f1a\u5bf9\u5e94\u4e00\u4e2a C++ \u6a21\u5757\uff0c\u5b83\u4e3b\u8981\u662f\u5bf9\u5e95\u5c42\u7684\u4e00\u4e9b\u5c01\u88c5\u3002\u7b2c\u4e8c\u90e8\u5206\u662f\u4e0d\u4f9d\u8d56 Libuv \u548c\u7b2c\u4e09\u65b9\u5e93\u7684 C++ \u4ee3\u7801\uff0c\u6bd4\u65b9\u50cf Buffer \u6a21\u5757\u7684\u5b9e\u73b0\u3002\u7b2c\u4e09\u90e8\u5206 C++ \u4ee3\u7801\u662f V8 \u672c\u8eab\u7684\u4ee3\u7801\u3002<\/li>\n\n\n\n<li>3. C \u8bed\u8a00\u4ee3\u7801\u4e3b\u8981\u662f\u5305\u62ec Libuv \u548c\u7b2c\u4e09\u65b9\u5e93\u7684\u4ee3\u7801\uff0c\u5b83\u4eec\u90fd\u662f\u7eaf C \u8bed\u8a00\u5b9e\u73b0\u7684\u4ee3\u7801\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><strong>Node.js \u4e2d\u7684 Libuv<\/strong><\/p>\n\n\n\n<p>\u9996\u5148\u6765\u770b\u4e00\u4e0b Node.js \u4e2d\u7684 Libuv\uff0c\u4e0b\u9762\u4ece\u4e09\u4e2a\u65b9\u9762\u4ecb\u7ecd Libuv\u3002<\/p>\n\n\n\n<ul>\n<li>1. \u4ecb\u7ecd Libuv \u7684\u6a21\u578b\u548c\u9650\u5236<\/li>\n\n\n\n<li>2. \u4ecb\u7ecd\u7ebf\u7a0b\u6c60\u89e3\u51b3\u7684\u95ee\u9898\u548c\u5e26\u6765\u7684\u95ee\u9898<\/li>\n\n\n\n<li>3. \u4ecb\u7ecd\u4e8b\u4ef6\u5faa\u73af<\/li>\n<\/ul>\n\n\n\n<p>Libuv \u672c\u8d28\u4e0a\u662f\u4e00\u4e2a\u751f\u4ea7\u8005\u6d88\u8d39\u8005\u7684\u6a21\u578b\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"582\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-466-1024x582.png\" alt=\"\" class=\"wp-image-18195\" style=\"width:500px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-466-1024x582.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-466-300x170.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-466-768x436.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-466-1536x873.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-466-830x472.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-466-230x131.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-466-350x199.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-466-480x273.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-466.png 1598w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>\u4ece\u4e0a\u9762\u8fd9\u4e2a\u56fe\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5728 Libuv \u4e2d\u6709\u5f88\u591a\u79cd\u751f\u4ea7\u4efb\u52a1\u7684\u65b9\u5f0f\uff0c\u6bd4\u5982\u8bf4\u5728\u4e00\u4e2a\u56de\u8c03\u91cc\uff0c\u5728 Node.js \u521d\u59cb\u5316\u7684\u65f6\u5019\uff0c\u6216\u8005\u5728\u7ebf\u7a0b\u6c60\u5b8c\u6210\u4e00\u4e9b\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u8fd9\u4e9b\u65b9\u5f0f\u90fd\u53ef\u4ee5\u751f\u4ea7\u4efb\u52a1\u3002\u7136\u540e Libuv \u4f1a\u4e0d\u65ad\u7684\u53bb\u6d88\u8d39\u8fd9\u4e9b\u4efb\u52a1\uff0c\u4ece\u800c\u9a71\u52a8\u7740\u6574\u4e2a\u8fdb\u7a0b\u7684\u8fd0\u884c\uff0c\u8fd9\u5c31\u662f\u6211\u4eec\u4e00\u76f4\u8bf4\u7684\u4e8b\u4ef6\u5faa\u73af\u3002<\/p>\n\n\n\n<p>\u4f46\u662f\u751f\u4ea7\u8005\u7684\u6d88\u8d39\u8005\u6a21\u578b\u5b58\u5728\u4e00\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u6d88\u8d39\u8005\u548c\u751f\u4ea7\u8005\u4e4b\u95f4\uff0c\u600e\u4e48\u53bb\u540c\u6b65\uff1f\u6bd4\u5982\u8bf4\u5728\u6ca1\u6709\u4efb\u52a1\u6d88\u8d39\u7684\u65f6\u5019\uff0c\u8fd9\u4e2a\u6d88\u8d39\u8005\u4ed6\u5e94\u8be5\u5728\u5e72\u561b\uff1f\u7b2c\u4e00\u79cd\u65b9\u5f0f\u662f\u6d88\u8d39\u8005\u53ef\u4ee5\u7761\u7720\u4e00\u6bb5\u65f6\u95f4\uff0c\u7761\u9192\u4e4b\u540e\uff0c\u4ed6\u4f1a\u53bb\u5224\u65ad\u6709\u6ca1\u6709\u4efb\u52a1\u9700\u8981\u6d88\u8d39\uff0c\u5982\u679c\u6709\u7684\u8bdd\u5c31\u7ee7\u7eed\u6d88\u8d39\uff0c\u5982\u679c\u6ca1\u6709\u7684\u8bdd\u4ed6\u5c31\u7ee7\u7eed\u7761\u7720\u3002\u5f88\u663e\u7136\u8fd9\u79cd\u65b9\u5f0f\u5176\u5b9e\u662f\u6bd4\u8f83\u4f4e\u6548\u7684\u3002\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u662f\u6d88\u8d39\u8005\u4f1a\u628a\u81ea\u5df1\u6302\u8d77\uff0c\u4e5f\u5c31\u662f\u8bf4\u8fd9\u4e2a\u6d88\u8d39\u6240\u5728\u7684\u8fdb\u7a0b\u4f1a\u88ab\u6302\u8d77\uff0c\u7136\u540e\u7b49\u5230\u6709\u4efb\u52a1\u7684\u65f6\u5019\uff0c\u64cd\u4f5c\u7cfb\u7edf\u5c31\u4f1a\u5524\u9192\u5b83\uff0c\u76f8\u5bf9\u6765\u8bf4\uff0c\u8fd9\u79cd\u65b9\u5f0f\u662f\u66f4\u9ad8\u6548\u7684\uff0cLibuv \u91cc\u4e5f\u6b63\u662f\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"373\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-468-1024x373.png\" alt=\"\" class=\"wp-image-18197\" style=\"width:568px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-468-1024x373.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-468-300x109.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-468-768x280.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-468-1536x560.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-468-830x303.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-468-230x84.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-468-350x128.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-468-480x175.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-468.png 1596w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>\u8fd9\u4e2a\u903b\u8f91\u4e3b\u8981\u662f\u7531\u4e8b\u4ef6\u9a71\u52a8\u6a21\u5757\u5b9e\u73b0\u7684\uff0c\u4e0b\u9762\u770b\u4e00\u4e0b\u4e8b\u4ef6\u9a71\u52a8\u7684\u5927\u81f4\u7684\u6d41\u7a0b\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"309\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-469-1024x309.png\" alt=\"\" class=\"wp-image-18198\" style=\"width:560px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-469-1024x309.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-469-300x90.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-469-768x232.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-469-1536x463.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-469-830x250.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-469-230x69.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-469-350x106.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-469-480x145.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-469.png 1598w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>\u5e94\u7528\u5c42\u4ee3\u7801\u53ef\u4ee5\u901a\u8fc7\u4e8b\u4ef6\u9a71\u52a8\u6a21\u5757\u8ba2\u9605 fd \u7684\u4e8b\u4ef6\uff0c\u5982\u679c\u8fd9\u4e2a\u4e8b\u4ef6\u8fd8\u6ca1\u6709\u51c6\u5907\u597d\u7684\u8bdd\uff0c\u90a3\u4e48\u8fd9\u4e2a\u8fdb\u7a0b\u5c31\u4f1a\u88ab\u6302\u8d77\u3002\u7136\u540e\u7b49\u5230\u8fd9\u4e2a fd \u6240\u5bf9\u5e94\u7684\u4e8b\u4ef6\u89e6\u53d1\u4e86\u4e4b\u540e\uff0c\u5c31\u4f1a\u901a\u8fc7\u4e8b\u4ef6\u9a71\u52a8\u6a21\u5757\u56de\u8c03\u5e94\u7528\u5c42\u7684\u4ee3\u7801\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u4ee5 Linux \u7684 \u4e8b\u4ef6\u9a71\u52a8\u6a21\u5757 epoll \u4e3a\u4f8b\uff0c\u6765\u770b\u4e00\u4e0b\u4f7f\u7528\u6d41\u7a0b\u3002<\/p>\n\n\n\n<ul>\n<li>1. \u9996\u5148\u901a\u8fc7 epoll_create \u53bb\u521b\u5efa\u4e00\u4e2aepoll \u5b9e\u4f8b\u3002<\/li>\n\n\n\n<li>2. \u7136\u540e\u901a\u8fc7 epoll_ctl \u8fd9\u4e2a\u51fd\u6570\u8ba2\u9605\u3001\u4fee\u6539\u6216\u8005\u53d6\u6d88\u8ba2\u9605\u4e00\u4e2a fd \u7684\u4e00\u4e9b\u4e8b\u4ef6\u3002<\/li>\n\n\n\n<li>3. \u6700\u540e\u901a\u8fc7 epoll_wait \u53bb\u5224\u65ad\u5f53\u524d\u8ba2\u9605\u7684\u4e8b\u4ef6\u6709\u6ca1\u6709\u53d1\u751f\uff0c\u5982\u679c\u6709\u4e8b\u60c5\u8981\u53d1\u751f\u7684\u8bdd\uff0c\u90a3\u4e48\u5c31\u76f4\u63a5\u6267\u884c\u4e0a\u5c42\u56de\u8c03\uff0c\u5982\u679c\u6ca1\u6709\u4e8b\u4ef6\u53d1\u751f\u7684\u8bdd\uff0c\u8fd9\u79cd\u65f6\u5019\u53ef\u4ee5\u9009\u62e9\u4e0d\u963b\u585e\uff0c\u5b9a\u65f6\u963b\u585e\u6216\u8005\u4e00\u76f4\u963b\u585e\uff0c\u76f4\u5230\u6709\u4e8b\u4ef6\u53d1\u751f\u3002\u8981\u4e0d\u8981\u963b\u585e\u6216\u8005\u8bf4\u963b\u585e\u591a\u4e45\uff0c\u662f\u6839\u636e\u5f53\u524d\u7cfb\u7edf\u7684\u60c5\u51b5\u3002\u6bd4\u5982 Node.js \u91cc\u9762\u5982\u679c\u6709\u5b9a\u65f6\u5668\u7684\u8282\u70b9\u7684\u8bdd\uff0c\u90a3\u4e48 Node.js \u5c31\u4f1a\u5b9a\u65f6\u963b\u585e\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u4fdd\u8bc1\u5b9a\u65f6\u5668\u53ef\u4ee5\u6309\u65f6\u6267\u884c\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u63a5\u4e0b\u6765\u518d\u6df1\u5165\u4e00\u70b9\u53bb\u770b\u4e00\u4e0b epoll \u7684\u5927\u81f4\u7684\u5b9e\u73b0\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"224\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-470-1024x224.png\" alt=\"\" class=\"wp-image-18199\" style=\"width:598px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-470-1024x224.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-470-300x66.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-470-768x168.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-470-1536x336.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-470-830x182.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-470-230x50.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-470-350x77.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-470-480x105.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-470.png 1590w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>\u5f53\u5e94\u7528\u5c42\u4ee3\u7801\u8c03\u7528\u4e8b\u4ef6\u9a71\u52a8\u6a21\u5757\u8ba2\u9605 fd \u7684\u4e8b\u4ef6\u65f6\uff0c\u6bd4\u5982\u8bf4\u8fd9\u91cc\u662f\u8ba2\u9605\u4e00\u4e2a\u53ef\u8bfb\u4e8b\u4ef6\u3002\u90a3\u4e48\u4e8b\u4ef6\u9a71\u52a8\u6a21\u5757\u5b83\u5c31\u4f1a\u5f80\u8fd9\u4e2a fd \u7684\u961f\u5217\u91cc\u9762\u6ce8\u518c\u4e00\u4e2a\u56de\u8c03\uff0c\u5982\u679c\u5f53\u524d\u8fd9\u4e2a\u4e8b\u4ef6\u8fd8\u6ca1\u6709\u89e6\u53d1\uff0c\u8fd9\u4e2a\u8fdb\u7a0b\u5b83\u5c31\u4f1a\u88ab\u963b\u585e\u3002\u7b49\u5230\u6709\u4e00\u5757\u6570\u636e\u5199\u5165\u4e86\u8fd9\u4e2a fd \u65f6\uff0c\u4e5f\u5c31\u662f\u8bf4\u8fd9\u4e2a fd \u6709\u53ef\u8bfb\u4e8b\u4ef6\u4e86\uff0c\u64cd\u4f5c\u7cfb\u7edf\u5c31\u4f1a\u6267\u884c\u4e8b\u4ef6\u9a71\u52a8\u6a21\u5757\u7684\u56de\u8c03\uff0c\u4e8b\u4ef6\u9a71\u52a8\u6a21\u5757\u5c31\u4f1a\u76f8\u5e94\u7684\u6267\u884c\u7528\u5c42\u4ee3\u7801\u7684\u56de\u8c03\u3002<\/p>\n\n\n\n<p>\u4f46\u662f epoll \u5b58\u5728\u4e00\u4e9b\u9650\u5236\u3002\u9996\u5148\u7b2c\u4e00\u4e2a\u662f\u4e0d\u652f\u6301\u6587\u4ef6\u64cd\u4f5c\u7684\uff0c\u6bd4\u65b9\u8bf4\u6587\u4ef6\u8bfb\u5199\u8fd9\u4e9b\uff0c\u56e0\u4e3a\u64cd\u4f5c\u7cfb\u7edf\u6ca1\u6709\u5b9e\u73b0\u3002\u7b2c\u4e8c\u4e2a\u662f\u4e0d\u9002\u5408\u6267\u884c\u8017\u65f6\u64cd\u4f5c\uff0c\u6bd4\u5982\u5927\u91cf CPU \u8ba1\u7b97\u3001\u5f15\u8d77\u8fdb\u7a0b\u963b\u585e\u7684\u4efb\u52a1\uff0c\u56e0\u4e3a epoll \u901a\u5e38\u662f\u642d\u914d\u5355\u7ebf\u7a0b\u7684\uff0c\u5982\u679c\u5728\u5355\u7ebf\u7a0b\u91cc\u6267\u884c\u8017\u65f6\u4efb\u52a1\uff0c\u5c31\u4f1a\u5bfc\u81f4\u540e\u9762\u7684\u4efb\u52a1\u65e0\u6cd5\u6267\u884c\u3002<\/p>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><strong>\u7ebf\u7a0b\u6c60\u89e3\u51b3\u7684\u95ee\u9898\u548c\u5e26\u6765\u7684\u95ee\u9898<\/strong><\/p>\n\n\n\n<p>\u9488\u5bf9\u8fd9\u4e2a\u95ee\u9898\uff0cLibuv \u63d0\u4f9b\u7684\u89e3\u51b3\u65b9\u6848\u5c31\u662f\u4f7f\u7528\u7ebf\u7a0b\u6c60\u3002\u4e0b\u9762\u6765\u770b\u4e00\u4e0b\u5f15\u5165\u4e86\u7ebf\u7a0b\u6c60\u4e4b\u540e\uff0c \u7ebf\u7a0b\u6c60\u548c\u4e3b\u7ebf\u7a0b\u7684\u5173\u7cfb\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"429\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-471-1024x429.png\" alt=\"\" class=\"wp-image-18200\" style=\"width:532px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-471-1024x429.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-471-300x126.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-471-768x322.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-471-1536x643.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-471-830x347.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-471-230x96.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-471-350x147.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-471-480x201.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-471.png 1610w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>\u4ece\u8fd9\u4e2a\u56fe\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u5f53\u5e94\u7528\u5c42\u63d0\u4ea4\u4efb\u52a1\u65f6\uff0c\u6bd4\u65b9\u8bf4\u50cf CPU \u8ba1\u7b97\u8fd8\u6709\u6587\u4ef6\u64cd\u4f5c\uff0c\u8fd9\u79cd\u65f6\u5019\u4e0d\u662f\u4ea4\u7ed9\u4e3b\u7ebf\u7a0b\u53bb\u5904\u7406\u7684\uff0c\u800c\u662f\u76f4\u63a5\u4ea4\u7ed9\u7ebf\u7a0b\u6c60\u5904\u7406\u7684\u3002\u7ebf\u7a0b\u6c60\u5904\u7406\u5b8c\u4e4b\u540e\u5b83\u4f1a\u901a\u77e5\u4e3b\u7ebf\u7a0b\u3002<\/p>\n\n\n\n<p>\u4f46\u662f\u5f15\u5165\u4e86\u591a\u7ebf\u7a0b\u540e\u4f1a\u5e26\u6765\u4e00\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u600e\u4e48\u53bb\u4fdd\u8bc1\u4e0a\u5c42\u4ee3\u7801\u8dd1\u5728\u5355\u4e2a\u7ebf\u7a0b\u91cc\u9762\u3002\u56e0\u4e3a\u6211\u4eec\u77e5\u9053 JS \u5b83\u662f\u5355\u7ebf\u7a0b\u7684\uff0c\u5982\u679c\u7ebf\u7a0b\u6c60\u5904\u7406\u5b8c\u4e00\u4e2a\u4efb\u52a1\u4e4b\u540e\uff0c\u76f4\u63a5\u6267\u884c\u4e0a\u5c42\u56de\u8c03\uff0c\u90a3\u4e48\u4e0a\u5c42\u4ee3\u7801\u5c31\u4f1a\u5b8c\u5168\u4e71\u4e86\u3002\u8fd9\u79cd\u65f6\u5019\u5c31\u9700\u8981\u4e00\u4e2a\u5f02\u6b65\u901a\u77e5\u7684\u673a\u5236\uff0c\u4e5f\u5c31\u662f\u8bf4\u5f53\u4e00\u4e2a\u7ebf\u7a0b\u5b83\u5904\u7406\u5b8c\u4efb\u52a1\u7684\u65f6\u5019\uff0c\u5b83\u4e0d\u662f\u76f4\u63a5\u53bb\u6267\u884c\u4e0a\u7a0b\u56de\u8c03\u7684\uff0c\u800c\u662f\u901a\u8fc7\u5f02\u6b65\u673a\u5236\u53bb\u901a\u77e5\u4e3b\u7ebf\u7a0b\u6765\u6267\u884c\u8fd9\u4e2a\u56de\u8c03\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"180\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-472-1024x180.png\" alt=\"\" class=\"wp-image-18201\" style=\"width:540px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-472-1024x180.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-472-300x53.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-472-768x135.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-472-1536x269.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-472-830x146.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-472-230x40.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-472-350x61.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-472-480x84.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-472.png 1620w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>Libuv \u4e2d\u5177\u4f53\u901a\u8fc7 fd \u7684\u65b9\u5f0f\u53bb\u5b9e\u73b0\u7684\u3002\u5f53\u7ebf\u7a0b\u6c60\u5b8c\u6210\u4efb\u52a1\u65f6\uff0c\u5b83\u4f1a\u4ee5\u539f\u5b50\u7684\u65b9\u5f0f\u53bb\u4fee\u6539\u8fd9\u4e2a fd \u4e3a\u53ef\u8bfb\u7684\uff0c\u7136\u540e\u5728\u4e3b\u7ebf\u7a0b\u4e8b\u4ef6\u5faa\u73af\u7684 Poll IO \u9636\u6bb5\u65f6\uff0c\u5b83\u5c31\u4f1a\u6267\u884c\u8fd9\u4e2a\u53ef\u8bfb\u4e8b\u4ef6\u7684\u56de\u8c03\uff0c\u4ece\u800c\u6267\u884c\u4e0a\u5c42\u7684\u56de\u8c03\u3002\u53ef\u4ee5\u770b\u5230\uff0cNode.js \u867d\u7136\u662f\u8dd1\u5728\u591a\u7ebf\u7a0b\u4e0a\u9762\u7684\uff0c\u4f46\u662f\u6240\u6709\u7684 JS \u4ee3\u7801\u90fd\u662f\u8dd1\u5728\u5355\u4e2a\u7ebf\u7a0b\u91cc\u7684\uff0c\u8fd9\u4e5f\u662f\u6211\u4eec\u7ecf\u5e38\u8ba8\u8bba\u7684 Node.js \u662f\u5355\u7ebf\u7a0b\u8fd8\u662f\u591a\u7ebf\u7a0b\u7684\uff0c\u4ece\u4e0d\u540c\u7684\u89d2\u5ea6\u53bb\u770b\u5c31\u4f1a\u5f97\u5230\u4e0d\u540c\u7684\u7b54\u6848\u3002<\/p>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><strong>\u4e00\u3001Node.js \u5f02\u6b65\u7684\u6838\u5fc3\u7ec4\u4ef6<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Node.js \u7684\u5f02\u6b65\u5b9e\u73b0\u4f9d\u8d56\u4e09\u5927\u6838\u5fc3\u7ec4\u4ef6\uff1a<\/p>\n\n\n\n<ol>\n<li><strong>V8 \u5f15\u64ce<\/strong>\uff1a\u89e3\u6790\u548c\u6267\u884c JavaScript \u4ee3\u7801\u3002<\/li>\n\n\n\n<li><strong>Libuv \u5e93<\/strong>\uff1a\u8de8\u5e73\u53f0\u7684\u5f02\u6b65 I\/O \u5f15\u64ce\uff0c\u8d1f\u8d23\u4e8b\u4ef6\u5faa\u73af\u3001\u7ebf\u7a0b\u6c60\u7ba1\u7406\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838<\/strong>\uff1a\u63d0\u4f9b\u5e95\u5c42\u7cfb\u7edf\u8c03\u7528\uff08\u5982\u6587\u4ef6\u8bfb\u5199\u3001\u7f51\u7edc\u8bf7\u6c42\uff09\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><strong>\u4e8c\u3001\u5e95\u5c42\u5b9e\u73b0\u793a\u4f8b\uff1a\u6587\u4ef6\u8bfb\u53d6\u7684\u5f02\u6b65\u8fc7\u7a0b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u4ee5\u8bfb\u53d6\u6587\u4ef6\u4e3a\u4f8b\uff0c\u770b Node.js \u5982\u4f55\u5b9e\u73b0\u5f02\u6b65\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">const fs = require('fs');\n\nconsole.log('1. \u5f00\u59cb\u6267\u884c');\n\nfs.readFile('\/path\/to\/file.txt', 'utf8', (err, data) => {\n  console.log('3. \u6587\u4ef6\u5185\u5bb9:', data);\n});\n\nconsole.log('2. \u7ee7\u7eed\u6267\u884c\u5176\u4ed6\u4efb\u52a1');<\/pre>\n\n\n\n<p><strong>\u5e95\u5c42\u6267\u884c\u6d41\u7a0b\u89e3\u6790<\/strong><\/p>\n\n\n\n<ol>\n<li><strong>JavaScript \u5c42\u7684\u8c03\u7528<\/strong>\n<ul>\n<li>\u8c03\u7528&nbsp;<code>fs.readFile<\/code>&nbsp;\u65f6\uff0cNode.js \u4e0d\u4f1a\u963b\u585e\u4e3b\u7ebf\u7a0b\uff0c\u800c\u662f\u5c06\u6587\u4ef6\u8bfb\u53d6\u4efb\u52a1\u4ea4\u7ed9\u5e95\u5c42\u5904\u7406\u3002<\/li>\n\n\n\n<li>\u56de\u8c03\u51fd\u6570&nbsp;<code>(err, data)<\/code>&nbsp;\u88ab\u6682\u5b58\uff0c\u7b49\u5f85\u6587\u4ef6\u8bfb\u53d6\u5b8c\u6210\u540e\u6267\u884c\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Libuv \u5e93\u7684\u4efb\u52a1\u5206\u53d1<\/strong>\n<ul>\n<li><strong>Libuv \u7684\u6838\u5fc3\u6a21\u5757<\/strong>\uff1a\n<ul>\n<li><strong>\u4e8b\u4ef6\u5faa\u73af\uff08Event Loop\uff09<\/strong>\uff1a\u7ba1\u7406\u4efb\u52a1\u6267\u884c\u987a\u5e8f\u3002<\/li>\n\n\n\n<li><strong>\u7ebf\u7a0b\u6c60\uff08Thread Pool\uff09<\/strong>\uff1a\u5904\u7406 CPU \u5bc6\u96c6\u578b\u5f02\u6b65\u4efb\u52a1\uff08\u5982\u6587\u4ef6\u8bfb\u5199\u3001\u52a0\u5bc6\u8ba1\u7b97\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u6587\u4ef6\u8bfb\u53d6\u7684\u5e95\u5c42\u5904\u7406<\/strong>\uff1a\n<ul>\n<li>\u7531\u4e8e\u6587\u4ef6\u8bfb\u5199\u5c5e\u4e8e\u963b\u585e\u64cd\u4f5c\uff0cLibuv \u4f1a\u5c06\u4efb\u52a1\u5206\u914d\u7ed9\u7ebf\u7a0b\u6c60\u4e2d\u7684\u4e00\u4e2a\u5de5\u4f5c\u7ebf\u7a0b\u3002<\/li>\n\n\n\n<li>\u4e3b\u7ebf\u7a0b\u7ee7\u7eed\u6267\u884c\u540e\u7eed\u4ee3\u7801\uff08\u8f93\u51fa&nbsp;<code>2. \u7ee7\u7eed\u6267\u884c\u5176\u4ed6\u4efb\u52a1<\/code>\uff09\uff0c\u4e0d\u88ab\u963b\u585e\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u64cd\u4f5c\u7cfb\u7edf\u7684\u5f02\u6b65 I\/O \u673a\u5236<\/strong>\n<ul>\n<li>\u5de5\u4f5c\u7ebf\u7a0b\u901a\u8fc7\u7cfb\u7edf\u8c03\u7528\uff08\u5982 Linux \u7684&nbsp;<code>pread<\/code>\uff09\u5411\u5185\u6838\u53d1\u8d77\u6587\u4ef6\u8bfb\u53d6\u8bf7\u6c42\u3002<\/li>\n\n\n\n<li>\u5185\u6838\u5904\u7406 I\/O \u64cd\u4f5c\u65f6\uff0c\u5de5\u4f5c\u7ebf\u7a0b\u4e0d\u4f1a\u963b\u585e\uff0c\u800c\u662f\u8fdb\u5165\u7b49\u5f85\u72b6\u6001\uff0c\u76f4\u5230\u5185\u6838\u5b8c\u6210\u6570\u636e\u8bfb\u53d6\u5e76\u901a\u77e5\u7ebf\u7a0b\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u7ed3\u679c\u56de\u8c03\u7684\u5904\u7406<\/strong>\n<ul>\n<li>\u5f53\u6587\u4ef6\u6570\u636e\u8bfb\u53d6\u5b8c\u6210\u540e\uff0c\u5185\u6838\u901a\u77e5 Libuv \u7684\u4e8b\u4ef6\u5faa\u73af\u3002<\/li>\n\n\n\n<li>\u4e8b\u4ef6\u5faa\u73af\u5c06\u56de\u8c03\u51fd\u6570\u653e\u5165&nbsp;<strong>\u5fae\u4efb\u52a1\u961f\u5217<\/strong>&nbsp;\u6216&nbsp;<strong>\u5b8f\u4efb\u52a1\u961f\u5217<\/strong>\uff08\u53d6\u51b3\u4e8e\u4efb\u52a1\u7c7b\u578b\uff09\uff0c\u7b49\u5f85\u4e3b\u7ebf\u7a0b\u7a7a\u95f2\u65f6\u6267\u884c\uff08\u8f93\u51fa&nbsp;<code>3. \u6587\u4ef6\u5185\u5bb9:<\/code>\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>\u4e0b\u9762\u7684\u56fe\u5c31\u662f\u5f02\u6b65\u4efb\u52a1\u5904\u7406\u7684\u4e00\u4e2a\u5927\u81f4\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>\u6bd4\u5982\u6211\u4eec\u60f3\u8bfb\u4e00\u4e2a\u6587\u4ef6\u7684\u65f6\u5019\uff0c\u8fd9\u65f6\u5019\u4e3b\u7ebf\u7a0b\u4f1a\u628a\u8fd9\u4e2a\u4efb\u52a1\u76f4\u63a5\u63d0\u4ea4\u5230\u7ebf\u7a0b\u6c60\u91cc\u9762\u53bb\u5904\u7406\uff0c\u7136\u540e\u4e3b\u7ebf\u7a0b\u5c31\u53ef\u4ee5\u7ee7\u7eed\u53bb\u505a\u81ea\u5df1\u7684\u4e8b\u60c5\u4e86\u3002\u5f53\u5728\u7ebf\u7a0b\u6c60\u91cc\u9762\u7684\u7ebf\u7a0b\u5b8c\u6210\u8fd9\u4e2a\u4efb\u52a1\u4e4b\u540e\uff0c\u5b83\u5c31\u4f1a\u5f80\u8fd9\u4e2a\u4e3b\u7ebf\u7a0b\u7684\u961f\u5217\u91cc\u9762\u63d2\u5165\u4e00\u4e2a\u8282\u70b9\uff0c\u7136\u540e\u4e3b\u7ebf\u7a0b\u5728 Poll IO \u9636\u6bb5\u65f6\uff0c\u5b83\u5c31\u4f1a\u53bb\u6267\u884c\u8fd9\u4e2a\u8282\u70b9\u91cc\u9762\u7684\u56de\u8c03\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1010\" height=\"908\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-464.png\" alt=\"\" class=\"wp-image-18193\" style=\"width:334px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-464.png 1010w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-464-300x270.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-464-768x690.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-464-830x746.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-464-230x207.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-464-350x315.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-464-480x432.png 480w\" sizes=\"(max-width: 1010px) 100vw, 1010px\" \/><\/figure><\/div>\n\n\n<p><strong>\u4e09\u3001Node.js \u4e8b\u4ef6\u5faa\u73af\u7684\u5e95\u5c42\u7ed3\u6784<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Node.js \u7684\u4e8b\u4ef6\u5faa\u73af\u5728 Libuv \u4e2d\u5206\u4e3a 6 \u4e2a\u9636\u6bb5\uff0c\u6bcf\u4e2a\u9636\u6bb5\u5904\u7406\u7279\u5b9a\u7c7b\u578b\u7684\u4efb\u52a1\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502           timers          \u2502 \uff08\u5904\u7406 setTimeout\/setInterval \u56de\u8c03\uff09\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502       I\/O callbacks       \u2502 \uff08\u5904\u7406\u5df2\u5b8c\u6210\u7684 I\/O \u64cd\u4f5c\u56de\u8c03\uff09\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502     idle, prepare         \u2502 \uff08\u5185\u90e8\u4f7f\u7528\uff09\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502       poll                \u2502 \uff08\u7b49\u5f85\u65b0\u7684 I\/O \u4e8b\u4ef6\uff09\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502       check               \u2502 \uff08\u5904\u7406 setImmediate \u56de\u8c03\uff09\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502       close callbacks     \u2502 \uff08\u5904\u7406 close \u4e8b\u4ef6\u56de\u8c03\uff09<\/pre>\n\n\n\n<p>\u5173\u952e\u9636\u6bb5\u793a\u4f8b\uff1apoll \u9636\u6bb5\u7684\u5de5\u4f5c\u673a\u5236<\/p>\n\n\n\n<ul>\n<li>\u5f53\u4e3b\u7ebf\u7a0b\u65e0\u540c\u6b65\u4efb\u52a1\u65f6\uff0c\u8fdb\u5165&nbsp;<code>poll<\/code>&nbsp;\u9636\u6bb5\uff0c\u7b49\u5f85\u65b0\u7684 I\/O \u4e8b\u4ef6\u3002<\/li>\n\n\n\n<li>\u82e5\u6709\u5df2\u5b8c\u6210\u7684 I\/O \u4efb\u52a1\uff08\u5982\u6587\u4ef6\u8bfb\u53d6\u7ed3\u679c\uff09\uff0c\u4e8b\u4ef6\u5faa\u73af\u4f1a\u6267\u884c\u8fd9\u4e9b\u4efb\u52a1\u7684\u56de\u8c03\u3002<\/li>\n\n\n\n<li>\u82e5&nbsp;<code>poll<\/code>&nbsp;\u9636\u6bb5\u7a7a\u95f2\u4e14\u5b58\u5728&nbsp;<code>setImmediate<\/code>&nbsp;\u4efb\u52a1\uff0c\u5219\u8fdb\u5165&nbsp;<code>check<\/code>&nbsp;\u9636\u6bb5\u6267\u884c\u8be5\u4efb\u52a1\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><strong>\u56db\u3001\u7ebf\u7a0b\u6c60\u4e0e\u5f02\u6b65\u64cd\u4f5c\u7c7b\u578b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Node.js \u7684\u7ebf\u7a0b\u6c60\uff08\u9ed8\u8ba4\u5927\u5c0f\u4e3a 4 \u4e2a\u7ebf\u7a0b\uff09\u7528\u4e8e\u5904\u7406\u4e24\u7c7b\u5f02\u6b65\u4efb\u52a1\uff1a<\/p>\n\n\n\n<ol>\n<li><strong>\u5fc5\u987b\u7531\u7ebf\u7a0b\u6c60\u5904\u7406\u7684\u4efb\u52a1<\/strong>\n<ul>\n<li>\u6587\u4ef6\u7cfb\u7edf\u64cd\u4f5c\uff08\u5982&nbsp;<code>fs.readFile<\/code>\uff09\u3001\u52a0\u5bc6\u8ba1\u7b97\uff08<code>crypto<\/code>&nbsp;\u6a21\u5757\uff09\u3001zlib \u538b\u7f29\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u793a\u4f8b\u573a\u666f<\/strong>\uff1a\u5f53\u8c03\u7528&nbsp;<code>fs.readFile<\/code>&nbsp;\u65f6\uff0cLibuv \u4ece\u7ebf\u7a0b\u6c60\u53d6\u51fa\u4e00\u4e2a\u7ebf\u7a0b\uff0c\u6267\u884c\u6587\u4ef6\u8bfb\u53d6\uff0c\u907f\u514d\u963b\u585e\u4e3b\u7ebf\u7a0b\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u53ef\u7531\u7cfb\u7edf\u76f4\u63a5\u5904\u7406\u7684\u5f02\u6b65\u4efb\u52a1<\/strong>\n<ul>\n<li>\u7f51\u7edc\u8bf7\u6c42\uff08<code>net<\/code>&nbsp;\u6a21\u5757\uff09\u3001DNS \u67e5\u8be2\u7b49\uff0c\u8fd9\u4e9b\u64cd\u4f5c\u4f9d\u8d56\u64cd\u4f5c\u7cfb\u7edf\u7684\u5f02\u6b65 I\/O \u80fd\u529b\uff08\u5982 Linux \u7684&nbsp;<code>epoll<\/code>\u3001Windows \u7684&nbsp;<code>IOCP<\/code>\uff09\uff0c\u65e0\u9700\u7ebf\u7a0b\u6c60\u53c2\u4e0e\u3002<\/li>\n\n\n\n<li><strong>\u793a\u4f8b\u573a\u666f<\/strong>\uff1a<code>http.get<\/code>&nbsp;\u53d1\u8d77\u7f51\u7edc\u8bf7\u6c42\u65f6\uff0cLibuv \u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u7684\u5f02\u6b65\u63a5\u53e3\u76f4\u63a5\u76d1\u542c\u6570\u636e\u8fd4\u56de\uff0c\u4e0d\u5360\u7528\u7ebf\u7a0b\u6c60\u8d44\u6e90\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><strong>\u4e94\u3001\u5f02\u6b65\u64cd\u4f5c\u7684\u6027\u80fd\u4f18\u5316\u793a\u4f8b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5f53\u5904\u7406\u5927\u91cf\u6587\u4ef6\u8bfb\u53d6\u65f6\uff0c\u7ebf\u7a0b\u6c60\u53ef\u80fd\u6210\u4e3a\u74f6\u9888\uff08\u9ed8\u8ba4\u4ec5 4 \u4e2a\u7ebf\u7a0b\uff09\uff0c\u53ef\u901a\u8fc7&nbsp;<code>worker_threads<\/code>&nbsp;\u6a21\u5757\u521b\u5efa\u66f4\u591a\u5de5\u4f5c\u7ebf\u7a0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">const fs = require('fs');\nconst { Worker } = require('worker_threads');\n\n\/\/ \u4e3b\u8fdb\u7a0b\nconsole.log('\u4e3b\u8fdb\u7a0b\u5f00\u59cb');\n\n\/\/ \u521b\u5efa\u5de5\u4f5c\u7ebf\u7a0b\u5904\u7406\u6587\u4ef6\u8bfb\u53d6\nconst worker = new Worker('.\/file-worker.js');\n\nworker.on('message', (data) => {\n  console.log('\u6587\u4ef6\u5185\u5bb9:', data);\n});\n\nconsole.log('\u4e3b\u8fdb\u7a0b\u7ee7\u7eed\u6267\u884c');\n\n\/\/ file-worker.js\uff08\u5de5\u4f5c\u7ebf\u7a0b\u4ee3\u7801\uff09\nconst fs = require('fs');\n\n\/\/ \u5de5\u4f5c\u7ebf\u7a0b\u4e2d\u6267\u884c\u6587\u4ef6\u8bfb\u53d6\uff0c\u4e0d\u5360\u7528\u4e3b\u7ebf\u7a0b\u6c60\u8d44\u6e90\nconst data = fs.readFileSync('\/path\/to\/large-file.txt', 'utf8');\nprocess.send(data);<\/pre>\n\n\n\n<p><strong>\u5e95\u5c42\u4f18\u5316\u539f\u7406<\/strong><\/p>\n\n\n\n<ul>\n<li>\u5de5\u4f5c\u7ebf\u7a0b\u62e5\u6709\u72ec\u7acb\u7684 V8 \u5b9e\u4f8b\u548c\u7ebf\u7a0b\u6c60\uff0c\u53ef\u5e76\u884c\u5904\u7406\u591a\u4e2a\u6587\u4ef6\u8bfb\u53d6\u4efb\u52a1\uff0c\u907f\u514d\u4e3b\u7ebf\u7a0b\u6c60\u8fc7\u8f7d\u3002<\/li>\n\n\n\n<li>\u4e3b\u7ebf\u7a0b\u4e0e\u5de5\u4f5c\u7ebf\u7a0b\u901a\u8fc7 IPC\uff08\u8fdb\u7a0b\u95f4\u901a\u4fe1\uff09\u673a\u5236\u4ea4\u6362\u6570\u636e\uff0c\u786e\u4fdd\u4e3b\u7ebf\u7a0b\u4e0d\u88ab\u963b\u585e\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><strong>\u603b\u7ed3\uff1aNode.js \u5f02\u6b65\u7684\u4e09\u5c42\u5b9e\u73b0\u6a21\u578b<\/strong><\/p>\n\n\n\n<ol>\n<li><strong>\u5e94\u7528\u5c42<\/strong>\uff1aJavaScript \u4ee3\u7801\u901a\u8fc7\u56de\u8c03\u51fd\u6570\u3001Promise\u3001Async\/Await \u5904\u7406\u5f02\u6b65\u903b\u8f91\u3002<\/li>\n\n\n\n<li><strong>\u5f15\u64ce\u5c42<\/strong>\uff1aLibuv \u5e93\u7ba1\u7406\u4e8b\u4ef6\u5faa\u73af\u3001\u7ebf\u7a0b\u6c60\uff0c\u5c06\u5f02\u6b65\u4efb\u52a1\u5206\u53d1\u5230\u7cfb\u7edf\u5e95\u5c42\u3002<\/li>\n\n\n\n<li><strong>\u7cfb\u7edf\u5c42<\/strong>\uff1a\u64cd\u4f5c\u7cfb\u7edf\u901a\u8fc7\u5f02\u6b65 I\/O \u63a5\u53e3\uff08\u5982 epoll\u3001IOCP\uff09\u5904\u7406\u5b9e\u9645\u7684\u786c\u4ef6\u64cd\u4f5c\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u3000\u3000<\/p>\n\n\n\n<p><strong>Node.js \u5f02\u6b65 = \u5feb\u9012\u7ad9\u7684\u300c\u524d\u53f0 + \u4ed3\u5e93\u300d\u6a21\u5f0f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5047\u8bbe\u4f60\u53bb\u5feb\u9012\u7ad9\u53d6\u5305\u88f9\uff1a<\/p>\n\n\n\n<ul>\n<li><strong>\u4e3b\u7ebf\u7a0b<\/strong>\uff1a\u50cf\u5feb\u9012\u7ad9\u7684\u524d\u53f0\u5c0f\u59d0\u59d0\uff0c\u8d1f\u8d23\u63a5\u5f85\u987e\u5ba2\u3001\u67e5\u5355\u53f7\u3001\u6253\u5305\uff0c\u4f46<strong>\u4e0d\u8d1f\u8d23\u53bb\u4ed3\u5e93\u627e\u5305\u88f9<\/strong>\uff08\u5426\u5219\u4f1a\u88ab\u5835\u5728\u4ed3\u5e93\uff0c\u6ca1\u6cd5\u63a5\u5f85\u5176\u4ed6\u4eba\uff09\u3002<\/li>\n\n\n\n<li><strong>\u5f02\u6b65\u4efb\u52a1<\/strong>\uff1a\u50cf \u201c\u627e\u67d0\u4e00\u4e2a\u5305\u88f9\u201d\uff0c\u6bd4\u5982\u4f60\u62a5\u51fa\u5355\u53f7\uff1a\u201c\u6211\u8981\u53d6 1024 \u53f7\u5305\u88f9\uff01\u201d<\/li>\n\n\n\n<li><strong>Libuv \u4ed3\u5e93\u5de5\u4eba<\/strong>\uff1a\u50cf\u4ed3\u5e93\u91cc\u7684\u5206\u62e3\u5458\uff0c\u4e13\u95e8\u8d1f\u8d23\u627e\u5305\u88f9\uff08\u5904\u7406\u8017\u65f6\u4efb\u52a1\uff09\u3002<\/li>\n\n\n\n<li><strong>\u4e8b\u4ef6\u5faa\u73af<\/strong>\uff1a\u50cf\u524d\u53f0\u7684 \u201c\u5f85\u529e\u5c0f\u672c\u672c\u201d\uff0c\u8bb0\u5f55\u54ea\u4e9b\u5305\u88f9\u627e\u5230\u4e86\u9700\u8981\u901a\u77e5\u987e\u5ba2\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p>\u53d6\u5305\u88f9\u7684\u5168\u8fc7\u7a0b\uff1a\u4ece\u62a5\u5355\u53f7\u5230\u62ff\u5230\u5305\u88f9<\/p>\n\n\n\n<p>\u573a\u666f\uff1a\u4f60\u62a5\u51fa\u5355\u53f7\uff0c\u8ba9\u524d\u53f0\u627e\u5305\u88f9\uff08\u5bf9\u5e94\u4ee3\u7801\u91cc\u7684\u6587\u4ef6\u8bfb\u53d6\uff09<\/p>\n\n\n\n<ol>\n<li>\u4f60\u5bf9\u524d\u53f0\u8bf4\uff1a\u201c\u6211\u8981 1024 \u53f7\u5305\u88f9\uff01\u201d\n<ul>\n<li>\u524d\u53f0\u5c0f\u59d0\u59d0\u4e0d\u4f1a\u81ea\u5df1\u51b2\u8fdb\u4ed3\u5e93\u7ffb\u5305\u88f9\uff08\u5426\u5219\u6ca1\u4eba\u63a5\u5f85\u540e\u9762\u7684\u987e\u5ba2\uff09\uff0c\u800c\u662f\u5bf9\u4ed3\u5e93\u5de5\u4eba\u558a\uff1a\u201c\u5e2e\u6211\u627e 1024 \u53f7\uff01\u201d\uff0c\u7136\u540e\u7ee7\u7eed\u7ed9\u4e0b\u4e00\u4e2a\u987e\u5ba2\u67e5\u5355\u53f7\uff08\u4e3b\u7ebf\u7a0b\u7ee7\u7eed\u6267\u884c\u540e\u7eed\u4ee3\u7801\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u4ed3\u5e93\u5de5\u4eba\u627e\u5305\u88f9\uff08\u8017\u65f6\u64cd\u4f5c\uff09\n<ul>\n<li>\u4ed3\u5e93\u6709\u591a\u4e2a\u5de5\u4eba\uff08\u7ebf\u7a0b\uff09\uff0c\u5176\u4e2d\u4e00\u4e2a\u5de5\u4eba\u63a5\u5230\u4efb\u52a1\u540e\uff0c\u94bb\u8fdb\u4ed3\u5e93\u627e\u5305\u88f9\u3002\u627e\u5305\u88f9\u9700\u8981\u65f6\u95f4\uff08\u6bd4\u5982\u5728\u8d27\u67b6\u95f4\u8dd1\u6765\u8dd1\u53bb\uff09\uff0c\u4f46\u5de5\u4eba\u4e0d\u80fd\u95f2\u7740\u73a9\u624b\u673a\uff0c<strong>\u5fc5\u987b\u4e00\u76f4\u627e\u76f4\u5230\u627e\u5230<\/strong>\uff08\u56e0\u4e3a\u627e\u5305\u88f9\u662f \u201c\u4f53\u529b\u6d3b\u201d\uff0c\u9700\u8981\u4eb2\u81ea\u7ffb\u627e\uff09\u3002\u4e0d\u8fc7\u8fd9\u65f6\u524d\u53f0\u8fd8\u5728\u5916\u9762\u6b63\u5e38\u63a5\u5f85\uff0c\u6ca1\u4eba\u88ab\u5361\u4f4f\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u5de5\u4eba\u627e\u5230\u5305\u88f9\uff0c\u544a\u8bc9\u524d\u53f0\n<ul>\n<li>\u627e\u5230\u5305\u88f9\u540e\uff0c\u5de5\u4eba\u558a\uff1a\u201c\u524d\u53f0\uff011024 \u53f7\u5305\u88f9\u627e\u5230\u4e86\uff01\u201d\uff0c\u524d\u53f0\u542c\u5230\u540e\uff0c\u628a\u8fd9\u4ef6\u4e8b\u8bb0\u5728 \u201c\u5f85\u529e\u5c0f\u672c\u672c\u201d \u4e0a\uff1a\u201c\u7b49\u6709\u7a7a\u4e86\u628a 1024 \u53f7\u7ed9\u987e\u5ba2\u201d\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u524d\u53f0\u6309\u5c0f\u672c\u672c\u987a\u5e8f\u53eb\u53f7\uff08\u4e8b\u4ef6\u5faa\u73af\u6267\u884c\u56de\u8c03\uff09\n<ul>\n<li>\u524d\u53f0\u5c0f\u59d0\u59d0\u624b\u91cc\u7684 \u201c\u5f85\u529e\u5c0f\u672c\u672c\u201d \u6709\u987a\u5e8f\uff1a\n<ul>\n<li>\u5148\u5904\u7406 \u201c\u9a6c\u4e0a\u8981\u8d85\u65f6\u7684\u5feb\u9012\u201d\uff08\u6bd4\u5982&nbsp;<code>setTimeout<\/code>&nbsp;\u50cf\u5feb\u9012\u6ede\u7559 24 \u5c0f\u65f6\u8981\u63d0\u9192\uff09\uff1b<\/li>\n\n\n\n<li>\u518d\u5904\u7406 \u201c\u5df2\u7ecf\u627e\u5230\u7684\u5305\u88f9\u201d\uff08\u6bd4\u5982\u4f60\u7684 1024 \u53f7\uff09\uff1b<\/li>\n\n\n\n<li>\u6700\u540e\u770b\u770b\u6709\u6ca1\u6709 \u201c\u52a0\u6025\u4ef6\u201d\uff08\u6bd4\u5982&nbsp;<code>setImmediate<\/code>&nbsp;\u50cf\u751f\u9c9c\u5feb\u9012\u8981\u4f18\u5148\u9001\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u7b49\u524d\u53f0\u5fd9\u5b8c\u5f53\u524d\u987e\u5ba2\uff0c\u5c31\u4f1a\u6309\u5c0f\u672c\u672c\u7684\u987a\u5e8f\u558a\u4f60\uff1a\u201c1024 \u53f7\u987e\u5ba2\uff0c\u4f60\u7684\u5305\u88f9\u597d\u4e86\uff01\u201d\uff08\u6267\u884c\u56de\u8c03\u51fd\u6570\uff0c\u628a\u5305\u88f9\u7ed9\u4f60\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>\u5982\u679c\u4ed3\u5e93\u5de5\u4eba\u4e0d\u591f\u7528\uff1f\u6bd4\u5982\u7a81\u7136\u6765\u4e86 100 \u4e2a\u53d6\u4ef6\u4eba<\/p>\n\n\n\n<p>\u5feb\u9012\u7ad9\u9ed8\u8ba4\u53ea\u6709 4 \u4e2a\u4ed3\u5e93\u5de5\u4eba\uff08Node.js \u7ebf\u7a0b\u6c60\u5927\u5c0f\u9ed8\u8ba4 4\uff09\uff0c\u5982\u679c\u540c\u65f6\u6709 100 \u4e2a\u4eba\u8981\u627e\u5305\u88f9\uff0c\u540e\u9762\u7684\u4eba\u53ea\u80fd\u6392\u961f\u7b49\u3002\u8fd9\u65f6\u5019\u53ef\u4ee5\uff1a<\/p>\n\n\n\n<ul>\n<li>\u591a\u5f00\u4e00\u4e2a\u4ed3\u5e93\uff08worker_threads<strong>\uff09<\/strong>\uff1a\u50cf\u5feb\u9012\u7ad9\u5f00\u5206\u5e97\uff0c\u6bcf\u4e2a\u5206\u5e97\u6709\u72ec\u7acb\u7684\u5de5\u4eba\uff0c\u540c\u65f6\u5904\u7406\u4e0d\u540c\u7684\u53d6\u4ef6\u4efb\u52a1\uff0c\u524d\u53f0\u5c0f\u59d0\u59d0\u4e0d\u7528\u7b49\u67d0\u4e00\u4e2a\u4ed3\u5e93\u5fd9\u5b8c\u3002<\/li>\n\n\n\n<li>\u8ba9\u673a\u5668\u4eba\u9001\u5305\u88f9\uff08\u7cfb\u7edf\u5f02\u6b65 I\/O\uff09\uff1a\u6bd4\u5982\u5bc4\u5feb\u9012\uff08\u7f51\u7edc\u8bf7\u6c42\uff09\u4e0d\u9700\u8981\u5de5\u4eba\u627e\u5305\u88f9\uff0c\u673a\u5668\u4eba\u76f4\u63a5\u626b\u7801\u51fa\u5e93\uff0c\u4e0d\u5360\u7528\u5de5\u4eba\u7684\u65f6\u95f4\uff0c\u524d\u53f0\u66f4\u9ad8\u6548\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u548c\u6d4f\u89c8\u5668\u7684\u533a\u522b\uff1a\u5feb\u9012\u7ad9 vs \u5c0f\u533a\u4fbf\u5229\u5e97<\/p>\n\n\n\n<ul>\n<li><strong>Node.js\uff08\u5feb\u9012\u7ad9\uff09<\/strong>\uff1a\u6709\u4e13\u4e1a\u4ed3\u5e93\u56e2\u961f\uff08\u7ebf\u7a0b\u6c60\uff09\u5904\u7406\u91cd\u6d3b\uff08\u627e\u5305\u88f9\uff09\uff0c\u524d\u53f0\u4e13\u6ce8\u63a5\u5f85\uff08\u4e3b\u7ebf\u7a0b\u5904\u7406\u4e1a\u52a1\uff09\uff0c\u9002\u5408\u5927\u91cf\u987e\u5ba2\u540c\u65f6\u6765\u53d6\u4ef6\uff08\u9ad8\u5e76\u53d1\u8bf7\u6c42\uff09\u3002<\/li>\n\n\n\n<li><strong>\u6d4f\u89c8\u5668\uff08\u5c0f\u533a\u4fbf\u5229\u5e97\uff09<\/strong>\uff1a\u6ca1\u6709\u4ed3\u5e93\u56e2\u961f\uff0c\u8001\u677f\u4e00\u4e2a\u4eba\u65e2\u8981\u770b\u5e97\u53c8\u8981\u627e\u8d27\uff08\u5355\u7ebf\u7a0b\uff09\uff0c\u9664\u975e\u558a\u90bb\u5c45\u6765\u5e2e\u5fd9\uff08Web Worker\uff09\uff0c\u5426\u5219\u6765\u592a\u591a\u987e\u5ba2\u5c31\u4f1a\u624b\u5fd9\u811a\u4e71\uff08\u9875\u9762\u5361\u987f\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<p>Node.js \u5f02\u6b65\u5c31\u50cf\uff1a\u524d\u53f0\u5c0f\u59d0\u59d0\u4e0d\u81ea\u5df1\u627e\u5305\u88f9\uff0c\u628a\u9ebb\u70e6\u4e8b\u4e22\u7ed9\u4ed3\u5e93\u5de5\u4eba\uff0c\u81ea\u5df1\u7ee7\u7eed\u63a5\u5f85\u987e\u5ba2\uff0c\u7b49\u5de5\u4eba\u627e\u5230\u5305\u88f9\u540e\uff0c\u6309\u5c0f\u672c\u672c\u987a\u5e8f\u53eb\u53f7\u3002\u8fd9\u6837\u5feb\u9012\u7ad9\u5c31\u80fd\u540c\u65f6\u670d\u52a1\u5f88\u591a\u4eba\uff0c\u4e0d\u4f1a\u56e0\u4e3a\u67d0\u4e2a\u4eba\u7684\u5305\u88f9\u96be\u627e\u800c\u6392\u961f\u5835\u8f66\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 Node.js \u7684\u5f02\u6b65\u7279\u6027\u662f\u5176\u9ad8\u6027\u80fd\u7684\u6838\u5fc3\u4f18\u52bf\uff0c\u5176\u5e95\u5c42\u5b9e\u73b0\u878d\u5408\u4e86 JavaScript \u4e8b\u4ef6\u5faa\u73af\u673a\u5236\u3001L [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/18189"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18189"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/18189\/revisions"}],"predecessor-version":[{"id":18203,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/18189\/revisions\/18203"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}