In this list, we want to collect links, resources, and tips towards sustainable software development.
We especially want to highlight practical real-world tips which are directly applicable in practice.
Supported with ❤️ by sandstorm
We are currently on our journey towards establishing sustainability goals and principles in our day-to-day work - and we want to collaborate with others and form a community around this.
Reducing Docker Image Size
Often, docker images are quite big in terms of image size - more than 1 GB is pretty common in "classical applications".
- Use the tool dive to analyze docker image size.
- Try to reduce the number of image layers and installed packages.
Avoid running apps as root
Consider Best practices
- Follow Best practices for writing Dockerfiles
- Follow Awesome Docker
Activate GZIP Compression
Gzip compression needs to be explicitly activated in the server config (nginx/apache). With this, you can easily reach big improvements for transferred data, especially for text-like content.
Configure HTTP Caching
By leveraging and properly configuring HTTP caching, you can also reduce data sizes quite a lot.
Common practices include:
- static assets (like JS/CSS) should be cached for a very long time and include a cache-bust mechanism
- f.e. in Neos CMS, Images are stored content-addressed (i.e. the URL changes if the image contents changes) - in this case, these assets can be also cached for a very long time.
- HTML pages should not have caching enabled, as this makes changing cached pages impossible during the cache lifetime.
Minify JS/CSS
JS/CSS/SCSS should be minified during the build. During this process, comments, white spaces etc are removed - and multiple scripts are concatenated to one big file (which is positive for compression ratios etc).
Use WebP format
Images are often responsible for most of the traffic. By using the WebP format, you can compress graphics lossy or lossless, such that they are 30% smaller than PNGs or JPGs.
By using the <picture>
tag, you can support fallbacks for older browsers.
Optimize your images
- use (lossy) compression
- consider dithering for your images
Lazyly load offscreen images
By loading offscreen images only, when they enter the viewport for the first time, you can drastically reduce the weight of your webpage and save a lot of transferred megabytes. See for example the new loading
attribute on image and iframe tags.
For support of older browsers see javascript solutions (e.g. https://github.com/aFarkas/lazysizes).
Reduce colors in images
For quite some PNG or GIF images, you can drastically reduce the number of colors until you notice a visual difference. Sometimes, 6 or 4 colors are enough, sometimes 32 or 16. With this trick, you can reduce up to 90% of the file size.
Only use pictures, where relevant
Pictures are a major source of traffic. Consider using less pictures, where they are not necessary, or transporting the information through different means (text, colors, …)
Use videos as little as possible
- avoid background videos
- avoid auto-playing videos
- compress your video
self host your fonts
When embeddings fonts from external font services, user data is passed to external parties. This is bad privacy practice. Opposed to this, self-hosted fonts add to the transmitted data.
Consider System Fonts
System fonts are already installed on your users device and don't need to be downloaded.
Optimize your font usage
- load only the font-weights you need
- use variable fonts as all styles can be embedded into one small file
- use the
woff2
file format, as it is the smallest to date - create a subset of only the characters you use
Caching for reducing CPU load
Prefer event pushing over event polling
"And now?", "And now?", "And now?", "And now?", "And now?"
minimize number of requests
minimize number of transmitted bytes
- minimize intermediate results
- … apply filter on server (instead of client)
- … or on database
- design APIs based on the user perspective
cache large results
render only what has changed
use existing metrics
Eg use web server logs to count number of visits per page.
track a sample set only
Do you need to track every visitor or one out of 100?
avoid dark patterns
For example in cookie banners, make the accept all and reject all button visually/hirarchically equally important. Clearly mark ads. Don't put pressure on your users ("only 3 left", "SALE: 7 hours left", …)
Think twice before using a pop-up
Can you inline consent modals for external content? Does your site really need external cookies?
plan for local development
Make your project starts with one or two commands. Consider using our Dev Script Runner
plan for staging environments
limit execution of CI/CD pipelines
- do I need to redeploy on readme changes
- and run E2E tests after typo fixes
testing
Make writing tests part of your projects. Use efficient test scopes (E2E tests versus unit test).
consider alternatives for tools and libraries when starting a project
- spring boot or micronaut
- react or preact or vue or next
- maven or gradle
- npm or yarn
- webpack or esbuild
- node or deno
- react-native or flutter
- electron or tauri
don't use AI for trivial tasks
Prefer adequate algorithms.
readable code
Follow best practices to structure your code, eg
enable others to maintain you project
- aim for open source projects
- do not re-implement things
- pick a license, which allows others to improve/continue the project
- use contracts, which allow your customers to migrate to another agency
measure and improve quality
What you can't measure, you can't manage. (Peter Drucker)
- use google lighthouse
- … or Pa11y
- linting
- sonarlint
- TODO: what else
abandon dead projects
only develop what will be used
shutdown idle servers
shutdown unused services
scale to zero or terminate
think of your data retention policy
delete no longer needed data, ie
- logs and statistics
- old application version
- CI/CD results and artifacts
co-locate small services
eg by using VMs, Kubernetes or serverless computing
choose green hosters
We use Hetzner.
Use a data centre close to your users
deploy a secure SSH configuration
ie no root and password logins
plan for regular updates
throttle metric collection
You do not need to check the remaining disk space every minute 😉.
Follow Awesome Accessibility
Base Research and Knowledge
-
Set of criteria for sustainable software (PDF)
This document is the outcome of the first of five work packages in the German Federal Environment Agency's UFOPLAN project “Sustainable software design— Development and application of criteria for resource-efficient software products with consideration of existing methods.
-
Demonstration of the application of set of criteria, including the definition of standard usage scenarios for chosen categories of software products. Discussion of the practicability of this type of assessment, its acceptability for several stakeholders and potential consequences for the eco-labeling of software products and sustainable software design.
-
Blue Angel: Resources and Energy-Efficient Software Products (DE-UZ 215)
The aim of the environmental label for resource and energy-efficient software products is to reduce the total energy consumed by information and communication technology and improve resource efficiency.
-
This paper states the different responsibilities of software designers regarding sustainability. It is helpful as a general framework to understand the different dimensions of sustainability.
-
Article: Software and sustainability - how do they fit together? (German)
How is software designed efficiently in the sense of the global sustainability goals and what does that actually mean? What models are there and who supports developers and administrators in implementing them?
-
Podcast: Das Sandpapier by Sandstorm Media: #42 Sustainable Software (German)
Sandstorm developers take a subjective look at sustainable software and evaluate the general and their own state of development. What role does sustainability actually play in software architecture? What are we already doing, what are our as yet unachieved goals, what are our plans and what obstacles still lie in the way?
-
Introduction in the Principles of Sustainable Software Engineering, Microsoft
Modular overview online course on the eight principles of sustainable software engineering.
-
Greenpeace Guide to Greener Electronics, 2017 (PDF)
In 2017, Greenpeace examined the 17 largest manufacturers of consumer electronics with regard to ecological production: How much and what kind of energy is used? Which resources are used in the process and how much? And what chemicals are in the products?
-
The article deals with the role of open source software in terms of economic sustainability and ethics.
-
nachhaltiges-webdesign.jetzt (German)
A collection of methods to create sustainable websites, that looks beyond technical measures at content, SEO, and business approaches.
Thank You Ole Langbehn @neurolabs for pointing us towards nachhaltiges-webdesign.jetzt.