{"id":221961,"date":"2021-07-19T08:16:21","date_gmt":"2021-07-19T00:16:21","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=221961"},"modified":"2021-07-07T11:16:54","modified_gmt":"2021-07-07T03:16:54","slug":"cloud-system-architecture","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/cloud-system-architecture.html","title":{"rendered":"\u51e0\u884c\u4ee3\u7801\u5c31\u641e\u5b9a\u9ad8\u7aef\u5927\u6c14\u7684\u4e91\u7cfb\u7edf\u67b6\u6784\u56fe"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u60f3\u77e5\u9053\u5982\u4f55\u7528Python\u4ee3\u7801\u7ed8\u5236\u51fa\u4e91\u7cfb\u7edf\u67b6\u6784\u56fe\uff0c\u90a3\u4e48\uff0c\u4eca\u5929\u733f\u59b9\u8981\u548c\u5927\u5bb6\u5206\u4eab\u7684\u8fd9\u4e2a\u5f00\u6e90\u9879\u76ee\u4f60\u4e00\u5b9a\u559c\u6b22\u2014\u2014diagrams\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u60f3\u77e5\u9053\u5982\u4f55\u7528Python\u4ee3\u7801\u7ed8\u5236\u51fa\u4e91\u7cfb\u7edf\u67b6\u6784\u56fe\uff0c\u90a3\u4e48\uff0c\u4eca\u5929\u733f\u59b9\u8981\u548c\u5927\u5bb6\u5206\u4eab\u7684\u8fd9\u4e2a\u5f00\u6e90\u9879\u76ee\u4f60\u4e00\u5b9a\u559c\u6b22\u2014\u2014diagrams\u3002
\n\"\"
\ndiagrams\u662f\u4e00\u4e2a\u4e0d\u9700\u8981\u4f7f\u7528\u4efb\u4f55\u7684\u8bbe\u8ba1\u5de5\u5177\uff0c\u53ea\u9700\u8981\u51e0\u884c\u4ee3\u7801\u5c31\u80fd\u505a\u51fa\u4e00\u5f20\u60ca\u8273\u7684\u4e91\u7cfb\u7edf\u67b6\u6784\u56fe\u7684\u5de5\u5177\uff0c\u5b83\u7684\u8bde\u751f\u5c31\u662f\u4e3a\u4e86\u5728\u6ca1\u6709\u4efb\u4f55\u8bbe\u8ba1\u5de5\u5177\u7684\u60c5\u51b5\u4e0b\u5bf9\u65b0\u7684\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u8fdb\u884c\u539f\u578b\u8bbe\u8ba1\uff0c\u4f60\u53ef\u4ee5\u7528\u5b83\u6765\u63cf\u8ff0\u6216\u8005\u53ef\u89c6\u5316\u73b0\u6709\u7684\u7cfb\u7edf\u67b6\u6784\uff0cdiagrams\u76ee\u524d\u652f\u6301AWS, Azure, GCP, Kubernetes, Alibaba Cloud, Oracle Cloud \u7b49\u3002\u540c\u65f6\uff0c\u5b83\u8fd8\u652f\u6301\u5185\u7f6e\u7684\u67b6\u6784\u56fe\u7ec4\u4ef6\u3001SaaS \u548c\u4e3b\u6d41\u7684\u7f16\u7a0b\u6846\u67b6\u548c\u8bed\u8a00\u3002Diagram as Code\u8fd8\u5141\u8bb8\u7528\u6237\u8ddf\u8e2a\u4efb\u4f55\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u4e2d\u7684\u67b6\u6784\u56fe\u66f4\u6539\u3002<\/p>\n

\u9664\u6b64\u4e4b\u5916\uff0c\u5982\u679c\u4f60\u719f\u6089Go\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528go-diagrams\u3002(\u9879\u76ee\u5730\u5740\uff1ahttps:\/\/github.com\/blushft\/go-diagrams)<\/p>\n

\"\"<\/p>\n

\u76ee\u524d\uff0cdiagrams\u5df2\u7ecf\u5728Github\u4e0a\u6807\u661f14.5K\uff0c\u7d2f\u8ba1\u5206\u652f 795 \u4e2a(Github\u5730\u5740\uff1ahttps:\/\/github.com\/mingrammer\/diagrams)<\/p>\n

\u5b89\u88c5\u8981\u6c42<\/strong><\/div>\n

diagrams\u652f\u6301Python 3.6\u53ca\u4ee5\u4e0a\u7248\u672c\uff0c\u5b83\u662f\u4f7f\u7528Graphviz\u6765\u6e32\u67d3\u56fe\u8868\uff0c\u56e0\u6b64\u60a8\u9700\u8981\u5b89\u88c5 Graphviz\u624d\u80fd\u4f7f\u7528\uff0c\u9996\u5148\u786e\u4fdd\u8fd9\u4e24\u9879\u7b26\u5408\u8981\u6c42\u4e4b\u540e\uff0c\u624d\u53ef\u4ee5\u5b89\u88c5diagrams\u3002macOS\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u4e0b\u8f7dGraphviz\uff1a<\/p>\n

\r\n# using pip (pip3) \r\n$ pip install diagrams \r\n \r\n# using pipenv \r\n$ pipenv install diagrams \r\n \r\n# using poetry \r\n$ poetry add diagrams\r\n<\/pre>\n
\u5feb\u901f\u5f00\u59cb<\/strong><\/div>\n
\r\n# diagram.py \r\nfrom diagrams import Diagram \r\nfrom diagrams.aws.compute import EC2 \r\nfrom diagrams.aws.database import RDS \r\nfrom diagrams.aws.network import ELB \r\n \r\nwith Diagram(\"Web Service\", show=False): \r\n    ELB(\"lb\") >> EC2(\"web\") >> RDS(\"userdb\") \r\n<\/pre>\n

\u6b64\u4ee3\u7801\u751f\u6210\u4e0b\u56fe\uff1a<\/p>\n

\r\n$ python diagram.py \r\n<\/pre>\n

\"\"
\n\u5b83\u5c06\u4fdd\u5b58web_service.png\u5728\u4f60\u7684\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002<\/p>\n

AWS \u4e0a\u7684\u5206\u7ec4\u5de5\u4f5c\u4eba\u5458<\/strong><\/div>\n
\r\nfrom diagrams import Diagram \r\nfrom diagrams.aws.compute import EC2 \r\nfrom diagrams.aws.database import RDS \r\nfrom diagrams.aws.network import ELB \r\n \r\nwith Diagram(\"Grouped Workers\", show=False, direction=\"TB\"): \r\n    ELB(\"lb\") >> [EC2(\"worker1\"), \r\n                  EC2(\"worker2\"), \r\n                  EC2(\"worker3\"), \r\n                  EC2(\"worker4\"), \r\n                  EC2(\"worker5\")] >> RDS(\"events\") \r\n<\/pre>\n

\"\"<\/p>\n

\u96c6\u7fa4\u7f51\u7edc\u670d\u52a1<\/strong><\/div>\n
\r\nfrom diagrams import Cluster, Diagram \r\nfrom diagrams.aws.compute import ECS \r\nfrom diagrams.aws.database import ElastiCache, RDS \r\nfrom diagrams.aws.network import ELB \r\nfrom diagrams.aws.network import Route53 \r\n \r\nwith Diagram(\"Clustered Web Services\", show=False): \r\n    dns = Route53(\"dns\") \r\n    lb = ELB(\"lb\") \r\n \r\n    with Cluster(\"Services\"): \r\n        svc_group = [ECS(\"web1\"), \r\n                     ECS(\"web2\"), \r\n                     ECS(\"web3\")] \r\n \r\n    with Cluster(\"DB Cluster\"): \r\n        db_main = RDS(\"userdb\") \r\n        db_main - [RDS(\"userdb ro\")] \r\n \r\n    memcached = ElastiCache(\"memcached\") \r\n \r\n    dns >> lb >> svc_group \r\n    svc_group >> db_main \r\n    svc_group >> memcached \r\n<\/pre>\n

\"\"<\/p>\n","protected":false},"excerpt":{"rendered":"

\u60f3\u77e5\u9053\u5982\u4f55\u7528Python\u4ee3\u7801\u7ed8\u5236\u51fa\u4e91\u7cfb\u7edf\u67b6\u6784\u56fe\uff0c\u90a3\u4e48\uff0c\u4eca\u5929\u733f\u59b9\u8981\u548c\u5927\u5bb6\u5206\u4eab\u7684\u8fd9\u4e2a\u5f00\u6e90\u9879\u76ee\u4f60\u4e00\u5b9a\u559c\u6b22\u2014\u2014diag […]<\/p>\n","protected":false},"author":1898,"featured_media":221967,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[711],"class_list":["post-221961","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread","tag-711"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1898"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=221961"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221961\/revisions"}],"predecessor-version":[{"id":221969,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221961\/revisions\/221969"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/221967"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=221961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=221961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=221961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}