Eco-design for web and mobile applications: develop sustainably!

Greenspector helps companies make their web and mobile applications more energy efficient. The French startup, based in Nantes, uses its online tool to identify energy-hungry features and design choices that result in energy resources being over used. While the impact of data centres on worldwide electricity use is often mentioned, and rightly so, it is probably time we explore eco-design when it comes to software too. And the scourge this eco-design means to combat: . Interview with Olivier Philippot, CTO at Greenspector.

It all started with three IT consultants concerned by the environmental footprint of IT projects. Appalled by the Internet’s growing energy consumption, (according to a recent Greenpeace report, if the internet were a country, it would be the sixth largest energy consumer in the world), they created a good practice guide and provide advice to companies on Green IT. However, teams are not always on board: “Makers have been taking energy efficiency into account when it comes to IT equipment for a few years already,” explains Olivier Philippot. The problem is that in the world of software development, computer resources are seen as abundant and decreasing in cost - a belief fueled by Moore’s law, connection rates that are continually rising, the development of cloud computing and services that facilitate horizontal scaling within infrastructures.

While the economic cost of sub-optimized computer programs is not terribly significant for a single application, the ecological cost grows in proportion to the increasing presence of digital technologies in our daily lives. “We are not advocating a backward vision” says Olivier Philippot. “We are just saying that the advantages of technologies are so often praised, that it is important for us to also open our eyes to their damaging effects. Especially because we can improve things!”

Measuring the cost of each feature and asking if it is worth it

Greenspector was created in 2010. It designed an SaaS tool that accurately measures the resources used by an application when run on the leading equipment on the market (tablets and smartphones). Energy, CPU and RAM use, data sharing via the device’s different network interfaces and impact on the battery charge level: some operating systems do provide this information, but it is not always the case. “Android, for example, provides users with a list of applications to see how much data and battery power they are using. It is possible to obtain more detailed metrics by doing further research and reverse-engineering. Obtaining this data with Apple devices is much more arduous, but we are very close. We are also working on the possibility of measuring the efficiency of IoT applications. The number of connected objects is rising rapidly and will soon exceed the number of regular devices.” This is a big challenge, because cards and operating systems are very diverse when it comes to IoT. For Apple devices and connected objects, Greenspector has developed energy sensors that monitor the electronic components directly to show how they perform via an API. The Greenspector platform, hosted by OVH, then analyzes the data. It provides developers with the various metrics via a dashboard displaying different meters.

“First we tried analyzing code, and then realized that it was not the best approach. The measurements were far from complete, because requests and external elements like libraries, which are more frequently integrated into code, can be highly resource intensive. With our tool, the developer knows the exact cost of each feature. He or she is then best placed to optimize the code, or identify the culprits using profiling tools if necessary.”

Often, they go further than just optimizing the code. Measuring the cost of certain features sometimes leads the developer to ask if they are really worth it. “An application’s performance is tested frequently: response times, display times, interface fluidity, and so on. The metrics provided by Greenspector makes another approach possible. When we think in terms of cost, we realize that certain features are very expensive for what they do. Image sliders, a trend in web design despite being generally disliked by users, use up a lot of resources. One of our customers improved their site’s energy efficiency by 80% when they removed them! To take another example: we know that 90% of users only look at the 1st results page when they submit a query to a search engine. But it always calculates several dozen result pages right away. Can’t we think of other ways of doing things?”

Factors leading to over-consumption are multiple, and sometimes unexpected

The huge rise in mobile internet use (overtaking desktop in October 2016) has led web developers to work harder to make web applications more efficient. But there is still a lot of “bloat”, according to Olivier Philippot. And the large-scale use of tracking tools has not improved things, multiplying remote server requests during application use or website visits. On top of that, we do not always realize when code is not optimized: “People often use tools like Cache systems and CDN, or techniques like placing JavaScript at the bottom of the page so processing happens after the page’s main elements are charged. These technologies or ‘good practices’ improve gross performance while masking anything weighing down the code in the actual applications.”

Developers have also been taking advantage of smartphones’ increasing power (the latest models have processors with up to 8 cores), transferring a lot of the processing to the user. “It is not strictly a bad idea, because the link between customer and server, as well as data sharing, uses a lot of power.” But again, we must not be dogmatic: when processing is not tied to individual data, it can be more efficient to carry out the calculations on the server side. These will then be pooled and cached for thousands or millions of users.

From the energy efficiency perspective, startups surprisingly do not perform much better than large companies, according to Olivier Philippot. “Large companies have a certain technical debt, and use old, fairly energy-intensive frameworks. But the agile methods popular among startups, which create very short development cycles, have their own negative effects. They use frameworks that allow them to move quickly, like Angular.JS, which create an enormous number of requests and events.”

It is difficult to recommend one language over another: “The developer’s skill set is a key factor. It is better to know PHP by heart and use it correctly, even though it is known for being heavy, rather than using HTML 5 + JavaScript in a less controlled way. There are no magic answers, but getting into the habit of measuring your code’s performance and skillfully optimizing your developing environment is a good start.” What’s more, languages like Java that promise to manage material complexity (memory, lower levels...), suggest they are more efficient. In truth this is not always the case: these high level languages are based on an execution environment, notably a JVM (Java Virtual Machine), that run a [url=""]Garbage Collector[/url] algorithm. This recuperates memory by automatically recycling the memory allocated to objects not in use. This relieves the developer from this tedious task, which lightens the code. The problem is that the garbage collector algorithms are not perfect. Bugs causing memory leaks are not uncommon, and GCs are often too frequent and energy intensive. Ultimately, the most efficient programming languages in terms of energy are the low-level languages, closest to the instructions understood by a processor.

Likewise, because abstraction mechanisms use up resources, it becomes clear that native applications developed for each of the different mobile operating systems are more efficient that the hybrid versions developed using the Apache Cordova framework. Code stacking is a source of inefficiency. We rarely take time to clean code up, which means that useless, redundant conditions multiply in the program. This leads to processing that is often unnecessary.

Mobility and pay-per-use infrastructures will make developers more environmentally friendly

With the only tool of its kind in the world, Greenspector’s team of 14 staff members has won over large groups including Orange, La Poste, LVMH, SNCF and Merck. If the French startup is focusing on auditing mobile applications, it’s because this gives the user a more immediate advantage: “Whether it’s a matter of mobile applications for the general public or business-specific applications, used by train conductors or postmen for example, the problem of battery life is a powerful lever. And Google and Apple are starting to promote economical applications." On the contrary, it’s harder to convince IT departments to optimize the code for applications hosted on their internal infrastructures or by a web host: “When what’s to be gained from refactoring the code is to turn off a few virtual computers on an infrastructure that has several dozen or even hundreds, it’s hard to motivate the teams to act.” But Olivier Philippot is convinced that pay-per-use cloud computing instances, which is becoming more and more common, will make developers think harder about their code’s energy efficiency. Savings will be easier to quantify. This is a question of maturity.

Perhaps in the future we will see labels to encourage environmentally friendly applications. “What is currently an approach that breaks with the status quo, in terms of the relatively low hosting costs in the internet’s current economic model, will become the norm. Awareness is rising. Among large groups and public organizations, eco-design is appearing in web project specifications. And just look at the number of articles on the environmental consequences of Bitcoin mining or the widespread use of Blockchain technology. We are thinking about the impact of technologies before imagining industrial uses. That’s something new!”. Greenspector is determined to help raise awareness on this issue. In a few weeks it will launch a free online tool to allow everyone to see how efficient an application or website really is.

• Green Code Lab tools:
• Greenspector blog: