Skip to content

Commit 63e64e9

Browse files
authored
[Backend] Docs for Backend architecture (Backend.Edge.App) (#3818)
The backend Architecture page was empty. Document how an OpenEMS Edge connects to the Backend via the Backend.Edge.App: the Edge-facing endpoint was split out of the central Backend into its own scalable application, so the Edge Controller.Api.Backend connects to a Backend.Edge.App (deployed on separate servers, or on the central server via localhost) which relays to the central Edge.Manager. Follows up on the discussion in #3795. https://openems.github.io/openems.io/openems/latest/backend/architecture.html Signed-off-by: arindahills <293051436+arindahills@users.noreply.github.com> Co-authored-by: arindahills <293051436+arindahills@users.noreply.github.com>
1 parent 1867b4f commit 63e64e9

1 file changed

Lines changed: 58 additions & 1 deletion

File tree

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,59 @@
11
= Backend Architecture
2-
:imagesdir: ../../assets/images
2+
:sectnums:
3+
:sectnumlevels: 4
4+
:toclevels: 4
5+
:experimental:
6+
:keywords: AsciiDoc
7+
:source-highlighter: highlight.js
8+
:icons: font
9+
:imagesdir: ../../assets/images
10+
11+
OpenEMS Backend runs on a (cloud) server. It connects the decentralized OpenEMS Edge systems and provides aggregation, monitoring and control via the internet. Internally it is built from loosely coupled OSGi services, most importantly:
12+
13+
* *Metadata* (xref:backend/metadata.adoc[Metadata]) - identification and authorization of Edges and Users.
14+
* *Timedata* (xref:backend/timedata.adoc[Timedata]) - persistence and query of historic data.
15+
* *Ui.Websocket* - the WebSocket endpoint for the OpenEMS UI.
16+
* *Edge.Manager* - the service that manages the connected OpenEMS Edges.
17+
* *Backend-to-Backend* (xref:backend/backend-to-backend.adoc[Backend-to-Backend]) - APIs for third-party systems.
18+
19+
== Connecting OpenEMS Edge
20+
21+
An OpenEMS Edge connects to the Backend using its `Controller.Api.Backend` over a WebSocket connection. Historically the Edge-facing endpoint was a component running inside the central Backend server. To be able to scale to a large number of Edges, this endpoint was separated into its own application, the *Backend.Edge.App*, which can be deployed on one or more independent servers.
22+
23+
The general setup is:
24+
25+
....
26+
[OpenEMS Edge] [OpenEMS Edge] [OpenEMS Edge] ...
27+
| | |
28+
| WebSocket (Controller.Api.Backend) |
29+
v v v
30+
+--------------------------------------------------------------+
31+
| Backend.Edge.App | <- Edge-facing server(s)
32+
| (accepts Edge connections, relays messages) | (one or more, scalable)
33+
+--------------------------------------------------------------+
34+
|
35+
| WebSocket
36+
v
37+
+--------------------------------------------------------------+
38+
| OpenEMS Backend (central) | <- Central server
39+
| Edge.Manager · Metadata · Timedata · Ui.Websocket |
40+
+--------------------------------------------------------------+
41+
....
42+
43+
The *Backend.Edge.App* acts as a proxy/relay between the OpenEMS Edges and the central Backend:
44+
45+
* it accepts the incoming WebSocket connections from the Edges (authenticating each Edge by its API-key),
46+
* it relays messages in both directions between the Edge and the central Backend's *Edge.Manager*, and
47+
* it keeps a local cache of connection state (e.g. the mapping of API-key to Edge-ID that it receives from the central Backend's Metadata service).
48+
49+
Because the Backend.Edge.App handles the protocol towards the central Backend, *the Edge `Controller.Api.Backend` does not need to be modified*: an Edge always connects to a Backend.Edge.App, regardless of how many Edge-facing servers are deployed.
50+
51+
=== Deployment options
52+
53+
* *Scaled setup*: run one or more Backend.Edge.App instances on separate physical servers, each connecting back to the central Backend's Edge.Manager. This distributes the Edge connections across several machines.
54+
* *Single-server setup*: run a single Backend.Edge.App on the central server itself and let it connect to the Backend's Edge.Manager on `localhost`. This is the simplest setup for small deployments.
55+
56+
[NOTE]
57+
====
58+
The Metadata service on the central Backend supplies the Backend.Edge.App with the API-key to Edge-ID mapping. When using File-based Metadata, make sure it provides this mapping (see xref:backend/metadata.adoc[Metadata]); the Odoo and Dummy Metadata implementations already do.
59+
====

0 commit comments

Comments
 (0)