Día 41: Configuración de Application Load Balancer con AWS EC2

Guía paso a paso para configurar un Application Load Balancer (ALB) con AWS EC2: desplegar dos instancias Ubuntu con Apache, crear ALB y Target Group, health checks y enrutamiento por ruta/host para microservicios.

3 sept 2025 • 3 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Día 41: configuración de un Application Load Balancer con AWS EC2

Conceptos clave

Qué es el balanceo de carga

El balanceo de carga distribuye el tráfico entrante entre varios servidores EC2 para lograr: • Mejor rendimiento al evitar que una sola instancia se sature • Mayor disponibilidad ya que si una instancia falla, el tráfico se redirige a instancias saludables • Escalado sin interrupciones al añadir o retirar servidores sin tiempo de inactividad

Elastic Load Balancing ELB

AWS ofrece Elastic Load Balancing para gestionar de forma automática la distribución del tráfico.

Tipos de balanceadores

1. Application Load Balancer ALB opera en Capa 7 HTTP HTTPS, admite enrutamiento avanzado por ruta y por host, ideal para microservicios. 2. Network Load Balancer NLB opera en Capa 4 TCP UDP, diseñado para alto rendimiento y latencia ultrabaja. 3. Classic Load Balancer CLB legado, opera en Capa 4 y 7, enrutamiento básico.

Solución paso a paso

Tarea 1: preparar instancias EC2

• Lanza 2 instancias EC2 con Ubuntu. • Añade un script de User Data para instalar Apache e iniciar un sitio simple. Ejemplo en una sola línea: #!/bin/bash; apt update -y; apt install apache2 -y; echo <h1>Hola desde Q2BSTUDIO</h1> > /var/www/html/index.html; systemctl start apache2; systemctl enable apache2 • Abre en el navegador las IP públicas de ambas instancias para verificar que ves tu página personalizada.

Tarea 2: crear un Application Load Balancer ALB

1. En la consola de EC2 ve a Load Balancers y crea un Application Load Balancer. 2. Configura esquema internet-facing, listener HTTP puerto 80 y selecciona tu VPC con subnets públicas en al menos dos zonas de disponibilidad. 3. Crea un Target Group de tipo instancia o IP y registra las dos EC2. 4. Revisa los health checks hasta que aparezcan en estado healthy. 5. Copia el nombre DNS del ALB, pégalo en el navegador y comprueba que alterna las respuestas entre tus dos servidores Apache round-robin.

Consejos prácticos

• Usa grupos de seguridad que permitan tráfico entrante al puerto 80 en el ALB y del ALB a las instancias. • Personaliza el health check path por ejemplo slash health para aplicaciones web. • Para HTTPS añade un certificado en el listener 443 con AWS Certificate Manager. • Para microservicios define reglas por ruta api, imagenes o por host api.tu-dominio.com apuntando a distintos target groups.

Cómo te ayuda Q2BSTUDIO

En Q2BSTUDIO impulsamos arquitecturas escalables y seguras en la nube con foco en alta disponibilidad, observabilidad y automatización. Nuestro equipo integra balanceo de carga, autoescalado, pipelines CI CD e infraestructura como código para acelerar tus despliegues y optimizar costes. Además ofrecemos desarrollo de aplicaciones a medida y software a medida, integración de inteligencia artificial e IA para empresas con agentes IA, ciberseguridad y pentesting, servicios inteligencia de negocio y analítica avanzada con power bi, todo respaldado por prácticas de gobierno y monitoreo.

Si estás dando tus primeros pasos con ALB y EC2 o quieres auditar y modernizar tu plataforma, descubre nuestros servicios cloud AWS y Azure para diseñar una arquitectura robusta, y potencia tus soluciones con inteligencia artificial aplicada a tus procesos.

Resultado esperado

Tras completar la guía, tu ALB distribuirá el tráfico entre dos instancias EC2 con Apache, mejorando rendimiento, disponibilidad y capacidad de escalado sin downtime. Esto sienta las bases para desplegar microservicios, añadir HTTPS, configurar reglas por ruta y automatizar el escalado con Auto Scaling Groups según la demanda.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat