Notas
16 de janeiro de 2024·2 min

Código verde

The other day I tried to calculate how many servers run 24/7 just to serve ads nobody clicks.

I didn't find the exact number. But I know it's obscene.

The elephant in the server room

The tech industry consumes about 4% of global energy. Seems small until you remember it's more than all civil aviation.

And what do we do with this energy?

I'm not judging. I also watch Netflix in 4K. But it's worth thinking about.

The code we write

Every line of inefficient code is wasted energy. Multiplied by millions of executions, it becomes burnt forest.

# This runs every hour, on millions of servers
for user in all_users:  # N queries
    send_notification(user)

# vs

users = get_all_users()  # 1 query
send_bulk_notification(users)

The difference seems small. But when you multiply by scale, by time, by datacenters around the world...

Micro-optimizations that matter (at scale)

Nothing revolutionary. Good practices that are also green practices.

The uncomfortable question

Every project should start with: does this need to exist?

Not every problem needs an app. Not every app needs microservices. Not every microservice needs Kubernetes.

Sometimes the most sustainable solution is a spreadsheet. Or a conversation. Or simply not doing it.

What I do (and don't do)

I won't pretend I'm carbon neutral. I run servers, use cloud, my dev setup consumes energy.

But I try to:

The paradox

The technology that causes the problem can also solve it. Route optimization reduces fuel. Smart grids save energy. Sensors prevent waste.

Code can be part of the solution. But first it needs to stop being part of the problem.


I don't have answers. Just the feeling that we should think more about this while writing that nested loop.