|
@@ -65,5 +65,131 @@ with Diagram(name="Advanced Web Service with On-Premises (colored)", show=False) |
|
|
>> Edge(color="darkorange") \ |
|
|
>> Edge(color="darkorange") \ |
|
|
>> aggregator |
|
|
>> aggregator |
|
|
``` |
|
|
``` |
|
|
|
|
|
![advanced web service with on-premise diagram colored](/img/advanced_web_service_with_on-premise_colored.png) |
|
|
|
|
|
|
|
|
![advanced web service with on-premises diagram colored](/img/advanced_web_service_with_on-premises_colored.png) |
|
|
|
|
|
|
|
|
## Less Edges |
|
|
|
|
|
|
|
|
|
|
|
As you can see on the previous graph the edges can quickly become noisy. Below are two examples to solve this problem. |
|
|
|
|
|
|
|
|
|
|
|
One approach is to get creative with the Node class to create blank placeholders, together with named nodes within Clusters, and then only pointing to single named elements within those Clusters. |
|
|
|
|
|
|
|
|
|
|
|
Compare the output below to the example output above . |
|
|
|
|
|
|
|
|
|
|
|
```python |
|
|
|
|
|
from diagrams import Cluster, Diagram, Node |
|
|
|
|
|
from diagrams.onprem.analytics import Spark |
|
|
|
|
|
from diagrams.onprem.compute import Server |
|
|
|
|
|
from diagrams.onprem.database import PostgreSQL |
|
|
|
|
|
from diagrams.onprem.inmemory import Redis |
|
|
|
|
|
from diagrams.onprem.aggregator import Fluentd |
|
|
|
|
|
from diagrams.onprem.monitoring import Grafana, Prometheus |
|
|
|
|
|
from diagrams.onprem.network import Nginx |
|
|
|
|
|
from diagrams.onprem.queue import Kafka |
|
|
|
|
|
|
|
|
|
|
|
with Diagram("\nAdvanced Web Service with On-Premise Less edges", show=False) as diag: |
|
|
|
|
|
ingress = Nginx("ingress") |
|
|
|
|
|
|
|
|
|
|
|
with Cluster("Service Cluster"): |
|
|
|
|
|
serv1 = Server("grpc1") |
|
|
|
|
|
serv2 = Server("grpc2") |
|
|
|
|
|
serv3 = Server("grpc3") |
|
|
|
|
|
|
|
|
|
|
|
with Cluster(""): |
|
|
|
|
|
blankHA = Node("", shape="plaintext", width="0", height="0") |
|
|
|
|
|
|
|
|
|
|
|
metrics = Prometheus("metric") |
|
|
|
|
|
metrics << Grafana("monitoring") |
|
|
|
|
|
|
|
|
|
|
|
aggregator = Fluentd("logging") |
|
|
|
|
|
blankHA >> aggregator >> Kafka("stream") >> Spark("analytics") |
|
|
|
|
|
|
|
|
|
|
|
with Cluster("Database HA"): |
|
|
|
|
|
db = PostgreSQL("users") |
|
|
|
|
|
db - PostgreSQL("replica") << metrics |
|
|
|
|
|
blankHA >> db |
|
|
|
|
|
|
|
|
|
|
|
with Cluster("Sessions HA"): |
|
|
|
|
|
sess = Redis("session") |
|
|
|
|
|
sess - Redis("replica") << metrics |
|
|
|
|
|
blankHA >> sess |
|
|
|
|
|
|
|
|
|
|
|
ingress >> serv2 >> blankHA |
|
|
|
|
|
|
|
|
|
|
|
diag |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
![advanced web service with on-premise less edges](/img/advanced_web_service_with_on-premise_less_edges.png) |
|
|
|
|
|
|
|
|
|
|
|
## Merged Edges |
|
|
|
|
|
|
|
|
|
|
|
Yet another option is to set the graph_attr dictionary key "concentrate" to "true". |
|
|
|
|
|
|
|
|
|
|
|
Note the following restrictions: |
|
|
|
|
|
|
|
|
|
|
|
1. the Edge must end at the same headport |
|
|
|
|
|
2. This only works when the "splines" graph_attr key is set to the value "spline". It has no effect when the value was set to "ortho", which is the default for the diagrams library. |
|
|
|
|
|
3. this will only work with the "dot" layout engine, which is the default for the diagrams library. |
|
|
|
|
|
|
|
|
|
|
|
For more information see: |
|
|
|
|
|
|
|
|
|
|
|
https://graphviz.gitlab.io/doc/info/attrs.html#d:concentrate |
|
|
|
|
|
|
|
|
|
|
|
https://www.graphviz.org/pdf/dotguide.pdf Section 3.3 Concentrators |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```python |
|
|
|
|
|
from diagrams import Cluster, Diagram, Edge, Node |
|
|
|
|
|
from diagrams.onprem.analytics import Spark |
|
|
|
|
|
from diagrams.onprem.compute import Server |
|
|
|
|
|
from diagrams.onprem.database import PostgreSQL |
|
|
|
|
|
from diagrams.onprem.inmemory import Redis |
|
|
|
|
|
from diagrams.onprem.aggregator import Fluentd |
|
|
|
|
|
from diagrams.onprem.monitoring import Grafana, Prometheus |
|
|
|
|
|
from diagrams.onprem.network import Nginx |
|
|
|
|
|
from diagrams.onprem.queue import Kafka |
|
|
|
|
|
|
|
|
|
|
|
graph_attr = { |
|
|
|
|
|
"concentrate": "true", |
|
|
|
|
|
"splines": "spline", |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
edge_attr = { |
|
|
|
|
|
"minlen":"3", |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
with Diagram("\n\nAdvanced Web Service with On-Premise Merged edges", show=False, |
|
|
|
|
|
graph_attr=graph_attr, |
|
|
|
|
|
edge_attr=edge_attr) as diag: |
|
|
|
|
|
|
|
|
|
|
|
ingress = Nginx("ingress") |
|
|
|
|
|
|
|
|
|
|
|
metrics = Prometheus("metric") |
|
|
|
|
|
metrics << Edge(minlen="0") << Grafana("monitoring") |
|
|
|
|
|
|
|
|
|
|
|
with Cluster("Service Cluster"): |
|
|
|
|
|
grpsrv = [ |
|
|
|
|
|
Server("grpc1"), |
|
|
|
|
|
Server("grpc2"), |
|
|
|
|
|
Server("grpc3")] |
|
|
|
|
|
|
|
|
|
|
|
blank = Node("", shape="plaintext", height="0.0", width="0.0") |
|
|
|
|
|
|
|
|
|
|
|
with Cluster("Sessions HA"): |
|
|
|
|
|
sess = Redis("session") |
|
|
|
|
|
sess - Redis("replica") << metrics |
|
|
|
|
|
|
|
|
|
|
|
with Cluster("Database HA"): |
|
|
|
|
|
db = PostgreSQL("users") |
|
|
|
|
|
db - PostgreSQL("replica") << metrics |
|
|
|
|
|
|
|
|
|
|
|
aggregator = Fluentd("logging") |
|
|
|
|
|
aggregator >> Kafka("stream") >> Spark("analytics") |
|
|
|
|
|
|
|
|
|
|
|
ingress >> [grpsrv[0], grpsrv[1], grpsrv[2],] |
|
|
|
|
|
[grpsrv[0], grpsrv[1], grpsrv[2],] - Edge(headport="w", minlen="1") - blank |
|
|
|
|
|
blank >> Edge(headport="w", minlen="2") >> [sess, db, aggregator] |
|
|
|
|
|
|
|
|
|
|
|
diag |
|
|
|
|
|
``` |
|
|
|
|
|
![advanced web service with on-premise merged edges](/img/advanced_web_service_with_on-premise_merged_edges.png) |