• No results found

Container diagram

Once you understand how your system fits in to the overall IT environment with acontext diagram, a really useful next step can be to illustrate the high-level technology choices with a container diagram.

Intent

A container diagram helps you answer the following questions.

1. What is the overall shape of the software system?

2. What are the high-level technology decisions?

3. How are responsibilities distributed across the system?

4. How do containers communicate with one another?

5. As a developer, where do I need to write code in order to implement features?

Structure

Draw a simple block diagram showing your key technology choices. For example, if you were diagramming a solution to thefinancial risk system, depending on your solution, you would draw the following sort of diagram.

Container diagram 117

Example container diagrams for the financial risk system (see appendix)

These example diagrams show the various web servers, application servers, standalone applications, databases, file systems, etc that make up the risk system. To enrich the diagram, often it’s useful to include some of the concepts from thecontext diagramdiagram, such as users and the other IT systems that the risk system has a dependency on.

Containers

By “containers”, I mean the logical executables, applications or processes that make up your software system; such as:

• Web servers and applications¹(e.g. Apache HTTP Server, Apache Tomcat, Microsoft IIS, WEBrick, etc)

• Application servers (e.g. IBM WebSphere, BEA/Oracle WebLogic, JBoss AS, etc)

• Enterprise service buses and business process orchestration engines (e.g. Oracle Fusion middleware, etc)

• SQL databases (e.g. Oracle, Sybase, Microsoft SQL Server, MySQL, PostgreSQL, etc)

• NoSQL databases (e.g. MongoDB, CouchDB, RavenDB, Redis, Neo4j, etc)

¹If multiple Java EE web applications or .NET websites are part of the same software system, they are usually executed in separate classloaders or AppDomains so I show them as separate containers because they are independent and require inter-process communication (e.g. remote method invocation, SOAP, REST, etc) to collaborate.

Container diagram 118

• Other storage systems (e.g. Amazon S3, etc)

• File systems (especially if you are reading/writing data outside of a database)

• Windows services

• Standalone/console applications (i.e. “public static void main” style applications)

• Web browsers and plugins

• cron and other scheduled job containers

For each container drawn on the diagram, you could specify:

• Name: The logical name of the container (e.g. “Internet-facing web server”, “Database”, etc)

• Technology: The technology choice for the container (e.g. Apache Tomcat 7, Oracle 11g, etc)

• Responsibilities: A very high-level statement or list of the container’s responsibilities.

You could alternatively show a small diagram of the key components that reside in each container, but I find that this usually clutters the diagram.

If you’re struggling to understand whether to include a box on a containers diagram, simply ask yourself whether that box will be (or can be) deployed on a separate piece of physical or virtual hardware. Everything that you show on a containers diagram should be deployable separately. This doesn’t mean that you must deploy them on separate infrastructure, but they should be able to be deployed separately.

Interactions

Typically, inter-container communication is inter-process communication. It’s very useful to explicitly identify this and summarise how these interfaces will work. As with any diagram, it’s useful to annotate the interactions rather than simply having a diagram with a collection of boxes and ambiguous lines connecting everything together. Useful information to add includes:

• The purpose of the interaction (e.g. “reads/writes data from”, “sends reports to”, etc).

• Communication method (e.g. Web Services, REST, Java Remote Method Invocation, Windows Communication Foundation, Java Message Service).

• Communication style (e.g. synchronous, asynchronous, batched, two-phase commit, etc)

• Protocols and port numbers (e.g. HTTP, HTTPS, SOAP/HTTP, SMTP, FTP, RMI/IIOP, etc).

Container diagram 119 System boundary

If you do choose to include users and IT systems that are outside the scope of what you’re building, it can be a good idea to draw a box around the appropriate containers to explicitly demarcate the system boundary. The system boundary corresponds to the single box that would appear on acontext diagram(e.g. “Risk System”).

Motivation

Where acontext diagramshows your software system as a single box, a container diagram opens this box up to show what’s inside it. This is useful because:

• It makes the high-level technology choices explicit.

• It shows where there are relationships between containers and how they communicate.

• It provides a framework in which to placecomponents(i.e. so that all components have a home).

• It provides the often missing link between a very high-levelcontext diagramand (what is usually) a very clutteredcomponent diagramshowing all of the logical components that make up the entire software system.

As with a context diagram, this should only take a couple of minutes to draw, so there really is no excuse not to do it either.

Audience

• Technical people inside and outside of the immediate software development team;

including everybody from software developers through to operational and support staff.

Example

The following diagram shows the logical containers that make up the techtribes.je website.

Container diagram 120

Container diagram 121 Put simply, techtribes.je is made up of an Apache Tomcat web server that provides users with information, and that information is kept up to date by a standalone content updater process.

All data is stored either in a MySQL database, a MongoDB database or the file system. It’s worth pointing out that this diagram says nothing about the number of physical instances of each container. For example, there could be a farm of web servers running against a MongoDB cluster, but this diagram doesn’t show that level of information. Instead, I show physical instances, failover, clustering, etc on a separatedeployment diagram. The containers diagram shows the high-level shape of the software architecture and how responsibilities are distributed across it. It also shows the major technology choices and how the containers communicate with one another. It’s a simple, high-level technology focussed diagram that is useful for software developers and support/operations staff alike.