By default, GreenFrame collects the usage metrics of a browser running the scenario. But you can also collect the metrics of the server components used to complete the scenario. This is called a full-stack analysis.
This way, you can determine where to focus your optimization efforts. You can also detect "pollution transfers", i.e. a reduction in the client that creates an increase in emissions on the server, or vice-versa. Pollution transfers don't change the overall emissions of the application, so they must be detected.
Running The Server-Side Components
For GreenFrame to collect the metrics of the server-side components, you must run them in the same environment as the browser, in docker containers. This is usually done with orchestration tools like Docker Compose or Kubernetes.
For instance, if your application runs a Node.js server and a PostgreSQL database, you probably have the following
command: "yarn dev"
command: "yarn start"
Before running the GreenFrame analysis, you must start your application containers. With docker-compose, that's as simple as running
Including Other Containers In The Analysis
Once the server components are running, get their names with
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d94f1c458c19 node:16 "docker-entrypoint.s…" 7 seconds ago Up 7 seconds 0.0.0.0:3003->3000/tcp enterprise_app
f024c10e666b node:16 "docker-entrypoint.s…" 7 seconds ago Up 7 seconds 0.0.0.0:3006->3006/tcp enterprise_api
b6b5f8eb9a6d postgres:13 "docker-entrypoint.s…" 8 seconds ago Up 8 seconds 0.0.0.0:5434->5432/tcp enterprise_db
Then, add the
--containers option to the
greenframe analyze command:
greenframe analyze https://localhost:3000/ ./my-scenario.js --containers="enterprise_app,enterprise_api,enterprise_db"
GreenFrame will then collect the metrics of these containers while running the scenario, in addition to its own browser container.
On the analysis page on greenframe.io, you will see the detail of each container.
The browser container often represents more than 80% of the total emissions. This is because GreenFrame counts the networking between the browser and the data center in the browser container.
Also, servers are optimized to process requests as fast as possible, so they are often more efficient than browsers.
GreenFrame computes the networking footprint differently for I/O inside and outside of the data center. To improve the accuracy of the analysis, separate the database containers by moving them to the
greenframe analyze https://localhost:3000/ ./my-scenario.js --containers="enterprise_app,enterprise_api" --databaseContainers="enterprise_db"