29Apr 2018

0

527

2

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 overuse of resources. While the impact of datacenters on worldwide electricity consumption is often mentioned, and rightly so, it is probably time we explore eco-design for software too. And the evil this eco-design means to combat? bloatwares. Interview with Olivier Philippot, CTO at Greenspector.

Hosted by DC3, the Greenspector platform provides developers with various metrics via a dashboard that displays different measurements.

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 provided advice to companies on green IT. However, teams are not always on board. “Manufacturers of IT equipment have been taking energy efficiency into account for a few years already,” explains Olivier Philippot. The problem is that in the world of software development, computing resources are seen as abundant and decreasing in cost – a belief fueled by Moore’s law, constantly increasing connection speeds, the development of cloud computing and services that facilitate horizontal scaling within infrastructures.

“Just like a gas naturally fills all available space, applications will use all the resources available on whatever server or smartphone they are running on.”

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). These resources include energy, CPU and RAM usage, data exchange via the device’s different network interfaces and impact on the battery level. Certain operating systems do provide this information, but it is not always the case. “Android, for example, provides users with a list of applications showing which ones are using the most data and battery power. It is possible to obtain more detailed metrics by doing further research and reverse engineering. Obtaining this data from Apple devices is much more difficult, 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 and transmit the results via an API. The Greenspector platform, hosted by DC3, then analyzes the data. It provides developers with the various metrics via a dashboard displaying different measurements.

“First we tried analyzing code, and then realized that it was not the best approach. The measurements were far from comprehensive, because requests and external elements like libraries, which are more and more frequently integrated into the code, can be highly resource intensive. With our tool, the developer knows the exact cost of each feature. They are then better able 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 make 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, consume 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 first results page when they submit a query to a search engine. But it always calculates several dozen results pages right away. Can’t we think of other ways of doing things?”

Multiple factors lead to over-consumption – and sometimes they’re the ones you don’t expect

The huge rise in mobile internet use (overtaking desktop internet use 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 caching systems and CDN, or techniques like placing JavaScript at the bottom of the page so processing happens in the background after the page’s main elements are loaded. These technologies or ‘good practices’ improve basic 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 eight 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 exchange, 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 AngularJS, and these create an enormous number of requests and events.”

It is nevertheless difficult to recommend one language over another. “The developer’s skill set is a key factor. It is better to know PHP inside out and use it correctly, even though it is known for being heavy, than use HTML5 + JavaScript in a less careful way. There is no silver bullet, but getting into the habit of measuring your code’s performance and skillfully optimizing your development environment is a good start.” What is more, languages like Java that claim to manage hardware complexity (memory management, lower layers…) like to suggest that 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 “Garbage Collector” algorithm. This reclaims 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.

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 is because this gives the user a more immediate advantage. “Whether it is about mobile applications for the general public or job-specific applications used by train conductors or postal workers, for example, the problem of battery life is a powerful lever. “https://greenspector.com/en/articles/2017-12-12-why-you-should-care-about-your-application-impact-on-battery-life Google and Apple are even starting to promote economical applications” .” In contrast, it is harder to convince IT departments to optimize the code for applications hosted on their internal infrastructures or by a web host. “When the gain to be won from refactoring the code is to turn off a few virtual machines on an infrastructure that has several dozen or even hundreds, it is hard to motivate the teams to act.” But Olivier Philippot is convinced that pay-per-use cloud computing instances, which are becoming more and more common, will make developers think harder about their code’s energy efficiency. Savings will be easier to quantify. It is a question of maturity.

Perhaps in the future we will see labels to encourage environmentally friendly applications. “This approach currently goes against the status quo, given the relatively low hosting costs in the internet’s current economic model, but it 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 devising industrial uses. That is 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.