{"id":71086,"date":"2024-02-02T10:45:09","date_gmt":"2024-02-02T02:45:09","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=71086"},"modified":"2024-02-02T10:45:10","modified_gmt":"2024-02-02T02:45:10","slug":"%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%aeapache-spark%e4%bb%a5%e4%bc%98%e5%8c%96%e5%a4%a7%e6%95%b0%e6%8d%ae%e5%a4%84%e7%90%86","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/71086.html","title":{"rendered":"\u5982\u4f55\u914d\u7f6eApache Spark\u4ee5\u4f18\u5316\u5927\u6570\u636e\u5904\u7406"},"content":{"rendered":"<p>\u6982\u8ff0\uff1aApache Spark\u914d\u7f6e\u5173\u952e\u5728\u4e8e<strong>1\u3001\u8c03\u6574\u5185\u5b58\u548c\u6838\u5fc3\u8d44\u6e90\u5206\u914d<\/strong>\u30012\u3001\u9009\u62e9\u5408\u9002\u7684\u5e8f\u5217\u5316\u5e93\u30013\u3001\u4f18\u5316\u6570\u636e\u5206\u533a\u30014\u3001\u8c03\u8282shuffle\u64cd\u4f5c\u548c5\u3001\u5e94\u7528\u9002\u5f53\u7684\u7f13\u5b58\u7b56\u7565\u3002<strong>\u5185\u5b58\u548c\u6838\u5fc3\u8d44\u6e90\u5206\u914d<\/strong> \u662fSpark\u6027\u80fd\u8c03\u4f18\u4e2d\u7684\u5173\u952e\u73af\u8282\uff0c\u6d89\u53ca\u5230\u5bf9executor\u5185\u5b58\u3001core\u6570\u91cf\u7684\u5408\u7406\u8bbe\u7f6e\u4ee5\u53ca\u5185\u5b58\u7f13\u51b2\u533a\u7684\u8c03\u6574\uff0c\u4ee5\u907f\u514d\u8d44\u6e90\u6d6a\u8d39\u548c\u8ba1\u7b97\u74f6\u9888\u3002<\/p>\n<h2><strong>\u4e00\u3001\u8c03\u6574\u5185\u5b58\u548c\u6838\u5fc3\u8d44\u6e90\u5206\u914d<\/strong><\/h2>\n<p>\u5728Spark\u96c6\u7fa4\u914d\u7f6e\u4e2d\uff0c\u5408\u7406\u7684\u8d44\u6e90\u5206\u914d\u5bf9\u6027\u80fd\u6709\u7740\u76f4\u63a5\u7684\u5f71\u54cd\u3002\u4e3a\u4e86<strong>\u4f18\u5316\u8d44\u6e90\u4f7f\u7528\u5e76\u63d0\u9ad8\u4f5c\u4e1a\u5904\u7406\u901f\u5ea6<\/strong>\uff0c\u5e94\u6839\u636e\u5e94\u7528\u9700\u6c42\u3001\u6570\u636e\u91cf\u548c\u96c6\u7fa4\u89c4\u6a21\u6765\u8bbe\u5b9aexecutor\u5185\u5b58\u548c\u6838\u5fc3\u6570\u91cf\u3002\u901a\u5e38\uff0c\u5e94\u907f\u514d\u8bbe\u7f6e\u9ad8\u5185\u5b58\u4e0e\u4f4e\u6838\u5fc3\u6570\u7684\u7ec4\u5408\uff0c\u56e0\u4e3a\u8fd9\u6837\u5bb9\u6613\u9020\u6210\u6838\u5fc3\u8d44\u6e90\u7684\u6d6a\u8d39\u548c\u6267\u884c\u8005\u9891\u7e41\u5207\u6362\u5bfc\u81f4\u7684\u5f00\u9500\u3002\u53cd\u8fc7\u6765\uff0c\u8fc7\u591a\u7684\u6838\u5fc3\u6570\u4e0e\u4e0d\u8db3\u7684\u5185\u5b58\u914d\u6bd4\uff0c\u53c8\u53ef\u80fd\u5f15\u53d1\u9891\u7e41\u7684\u5783\u573e\u6536\u96c6\u548c\u5185\u5b58\u6ea2\u51fa\u3002\u56e0\u800c\uff0c\u627e\u5230\u4e24\u8005\u95f4\u7684\u5e73\u8861\u70b9\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<h2><strong>\u4e8c\u3001\u9009\u62e9\u5408\u9002\u7684\u5e8f\u5217\u5316\u5e93<\/strong><\/h2>\n<p>\u5728\u5927\u6570\u636e\u5904\u7406\u4e2d\uff0c\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u662f\u5e38\u89c1\u64cd\u4f5c\uff0c\u76f4\u63a5\u5f71\u54cd\u7740\u6570\u636e\u7684\u4f20\u8f93\u901f\u7387\u548c\u5b58\u50a8\u6548\u7387\u3002Spark\u652f\u6301Kryo\u548cJava\u4e24\u79cd\u5e8f\u5217\u5316\u65b9\u5f0f\uff0c\u5176\u4e2d<strong>Kryo\u5e8f\u5217\u5316\u5e93\u76f8\u6bd4Java\u5e8f\u5217\u5316\u5177\u6709\u66f4\u5feb\u7684\u901f\u5ea6\u548c\u66f4\u5c0f\u7684\u5e8f\u5217\u5316\u540e\u4f53\u79ef<\/strong>\u3002\u56e0\u6b64\uff0c\u5728\u5904\u7406\u5927\u6570\u636e\u65f6\uff0c\u91c7\u7528Kryo\u5e8f\u5217\u5316\u901a\u5e38\u80fd\u591f\u663e\u8457\u63d0\u9ad8\u6027\u80fd\u3002\u7136\u800c\uff0c\u5e76\u4e0d\u662f\u6240\u6709\u7684\u6570\u636e\u7ed3\u6784\u90fd\u4e0eKryo\u517c\u5bb9\uff0c\u56e0\u6b64\u5e94\u6839\u636e\u5177\u4f53\u573a\u666f\u9009\u62e9\u5408\u9002\u7684\u5e8f\u5217\u5316\u5de5\u5177\u3002<\/p>\n<h2><strong>\u4e09\u3001\u4f18\u5316\u6570\u636e\u5206\u533a<\/strong><\/h2>\n<p>\u6570\u636e\u5206\u533a\u51b3\u5b9a\u4e86\u6570\u636e\u5728\u96c6\u7fa4\u8282\u70b9\u4e2d\u7684\u5206\u5e03\u65b9\u5f0f\uff0c\u76f4\u63a5\u5173\u7cfb\u5230\u5e76\u884c\u5904\u7406\u7684\u6548\u7387\u3002\u5982\u679c\u5206\u533a\u4e0d\u5747\u5300\uff0c\u4f1a\u5f15\u8d77\u67d0\u4e9b\u8282\u70b9\u8d1f\u8f7d\u8fc7\u91cd\u800c\u5176\u4ed6\u8282\u70b9\u7a7a\u95f2\uff0c\u9020\u6210\u8d44\u6e90\u7684\u4e0d\u5e73\u8861\u4f7f\u7528\u3002Spark\u5141\u8bb8\u7528\u6237<strong>\u5728\u6570\u636e\u52a0\u8f7d\u65f6\u6216\u901a\u8fc7\u8f6c\u6362\u64cd\u4f5c\u81ea\u5b9a\u4e49\u5206\u533a\u7b56\u7565<\/strong>\uff0c\u4ee5\u5b9e\u73b0\u66f4\u5e73\u8861\u7684\u6570\u636e\u5206\u5e03\u3002\u7406\u60f3\u7684\u5206\u533a\u80fd\u591f\u6700\u5927\u5316\u96c6\u7fa4\u7684\u5904\u7406\u80fd\u529b\uff0c\u51cf\u5c11\u6570\u636e\u5728\u8282\u70b9\u95f4\u7684\u79fb\u52a8\uff0c\u907f\u514d\u8ba1\u7b97\u70ed\u70b9\u3002<\/p>\n<h2><strong>\u56db\u3001\u8c03\u8282shuffle\u64cd\u4f5c<\/strong><\/h2>\n<p>Shuffle \u662fSpark\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u64cd\u4f5c\uff0c\u5b83\u6d89\u53ca\u6570\u636e\u7684\u91cd\u65b0\u5206\u5e03\u8fc7\u7a0b\uff0c\u901a\u5e38\u7528\u4e8egroupBy\u548creduceBy\u4e4b\u7c7b\u7684\u8f6c\u6362\u5904\u7406\u4e2d\u3002\u7136\u800c\uff0cshuffle\u64cd\u4f5c\u662f\u4e00\u4e2a\u8d44\u6e90\u5bc6\u96c6\u578b\u7684\u8fc7\u7a0b\uff0c\u5982\u679c\u4e0d\u52a0\u4ee5\u4f18\u5316\uff0c\u4f1a\u5927\u91cf\u6d88\u8017\u7f51\u7edc\u548cI\/O\u8d44\u6e90\uff0c\u62d6\u6162\u4efb\u52a1\u6267\u884c\u901f\u5ea6\u3002<strong>\u8c03\u8282Shuffle\u64cd\u4f5c\u7684\u6027\u80fd<\/strong> \u5173\u952e\u70b9\u5728\u4e8e\u51cf\u5c11\u6570\u636e\u4f20\u8f93\u91cf\u3001\u8c03\u6574buffer\u5927\u5c0f\u548c\u5e76\u884c\u5ea6\u3002\u8c03\u6574`spark.shuffle.file.buffer`\u548c`spark.reducer.maxSizeInFlight`\u7b49\u53c2\u6570\u80fd\u591f\u51cf\u5c11\u5199\u5165\u78c1\u76d8\u7684\u6b21\u6570\u548c\u6570\u636e\u4f20\u8f93\u7684\u4f53\u79ef\u3002<\/p>\n<h2><strong>\u4e94\u3001\u5e94\u7528\u9002\u5f53\u7684\u7f13\u5b58\u7b56\u7565<\/strong><\/h2>\n<p>\u5728Spark\u4e2d\uff0c\u6570\u636e\u7f13\u5b58\u80fd\u591f\u91cd\u590d\u4f7f\u7528\u4e2d\u95f4\u7ed3\u679c\uff0c\u907f\u514d\u591a\u6b21\u4ece\u78c1\u76d8\u8bfb\u5199\uff0c\u662f\u4f18\u5316\u6027\u80fd\u7684\u4e00\u79cd\u6709\u6548\u65b9\u5f0f\u3002\u9009\u62e9\u5408\u9002\u7684\u5b58\u50a8\u7ea7\u522b\uff08\u5982MEMORY_ONLY\u3001MEMORY_AND_DISK\u7b49\uff09\u5bf9\u4e8e\u5185\u5b58\u4f7f\u7528\u548c\u5904\u7406\u901f\u5ea6\u6709\u76f4\u63a5\u5f71\u54cd\u3002<strong>\u5229\u7528persist()\u6216cache()\u65b9\u6cd5\u8fdb\u884c\u5408\u9002\u7684\u6570\u636e\u7f13\u5b58<\/strong>\uff0c\u53ef\u4ee5\u51cf\u5c11\u91cd\u590d\u8ba1\u7b97\u7684\u5f00\u9500\uff0c\u52a0\u901f\u6574\u4e2a\u6570\u636e\u5904\u7406\u6d41\u7a0b\u3002\u6ce8\u610f\uff0c\u4e0d\u5fc5\u8981\u7684\u7f13\u5b58\u53ef\u80fd\u4f1a\u5360\u7528\u5b9d\u8d35\u7684\u5185\u5b58\u8d44\u6e90\uff0c\u56e0\u6b64\u7f13\u5b58\u7b56\u7565\u7684\u5e94\u7528\u9700\u8981\u8c28\u614e\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u4e94\u70b9\u7684\u914d\u7f6e\u548c\u4f18\u5316\uff0c\u53ef\u4ee5\u5927\u5e45\u63d0\u5347Apache Spark\u5904\u7406\u5927\u6570\u636e\u7684\u6548\u7387\u548c\u7a33\u5b9a\u6027\u3002\u6bcf\u4e00\u4e2a\u9879\u76ee\u548c\u6570\u636e\u96c6\u90fd\u6709\u5176\u72ec\u7279\u6027\uff0c\u56e0\u6b64\u9700\u8981\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u9002\u5f53\u7684\u8c03\u6574\u548c\u4f18\u5316\u3002<\/p>\n<p> <strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><strong>1. \u4ec0\u4e48\u662fApache Spark\u7684\u5e76\u884c\u5904\u7406\u65b9\u5f0f\uff1f<\/strong><br \/>\nApache Spark\u901a\u8fc7\u4f7f\u7528\u591a\u4e2a\u6267\u884c\u5668\u548c\u4efb\u52a1\u6765\u5b9e\u73b0\u5e76\u884c\u5904\u7406\u3002Spark\u5e94\u7528\u7a0b\u5e8f\u5c06\u4efb\u52a1\u5206\u53d1\u5230\u6267\u884c\u5668\u4e0a\u7684\u591a\u4e2a\u5de5\u4f5c\u5668\u8282\u70b9\uff0c\u5e76\u4e14\u6bcf\u4e2a\u5de5\u4f5c\u5668\u8282\u70b9\u90fd\u53ef\u4ee5\u5e76\u884c\u6267\u884c\u4efb\u52a1\uff0c\u4ee5\u63d0\u9ad8\u5904\u7406\u6548\u7387\u3002<\/p>\n<p><strong>2. \u5982\u4f55\u914d\u7f6eApache Spark\u7684\u5185\u5b58\u7ba1\u7406\uff1f<\/strong><br \/>\n\u5728\u914d\u7f6eApache Spark\u65f6\uff0c\u53ef\u901a\u8fc7\u4fee\u6539spark.executor.memory\u53c2\u6570\u6765\u8c03\u6574\u6bcf\u4e2a\u6267\u884c\u5668\u7684\u5185\u5b58\u5206\u914d\u5927\u5c0f\u3002\u540c\u65f6\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539spark.driver.memory\u53c2\u6570\u6765\u8c03\u6574\u9a71\u52a8\u5668\u7684\u5185\u5b58\u5206\u914d\u5927\u5c0f\u3002\u8fd9\u4e9b\u53c2\u6570\u7684\u5408\u7406\u914d\u7f6e\u53ef\u4ee5\u63d0\u9ad8\u5927\u6570\u636e\u5904\u7406\u7684\u6027\u80fd\u3002<\/p>\n<p><strong>3. \u8be5\u5982\u4f55\u914d\u7f6eApache Spark\u7684\u8d44\u6e90\u8c03\u5ea6\u5668\uff1f<\/strong><br \/>\nApache Spark\u63d0\u4f9b\u4e86\u591a\u79cd\u8d44\u6e90\u8c03\u5ea6\u5668\uff0c\u5982YARN\u3001Mesos\u548cStandalone\u7b49\u3002\u5728\u914d\u7f6e\u65f6\uff0c\u53ef\u4ee5\u6839\u636e\u96c6\u7fa4\u7684\u89c4\u6a21\u548c\u7279\u70b9\u9009\u62e9\u9002\u5408\u7684\u8d44\u6e90\u8c03\u5ea6\u5668\uff0c\u5e76\u901a\u8fc7\u8c03\u6574\u76f8\u5e94\u7684\u914d\u7f6e\u53c2\u6570\u6765\u4f18\u5316\u8d44\u6e90\u7684\u5206\u914d\u548c\u8c03\u5ea6\uff0c\u4ee5\u5b9e\u73b0\u5927\u6570\u636e\u5904\u7406\u7684\u9ad8\u6548\u6267\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u6982\u8ff0\uff1aApache Spark\u914d\u7f6e\u5173\u952e\u5728\u4e8e1\u3001\u8c03\u6574\u5185\u5b58\u548c\u6838\u5fc3\u8d44\u6e90\u5206\u914d\u30012\u3001\u9009\u62e9\u5408\u9002\u7684\u5e8f\u5217\u5316\u5e93\u30013\u3001\u4f18\u5316\u6570\u636e\u5206\u533a [&hellip;]","protected":false},"author":1,"featured_media":71088,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/71086"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=71086"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/71086\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/71088"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=71086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=71086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=71086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}