Performance Agent의 deploy.sh는 Connectivity Agent보다 한 단계 더 많은 작업을 수행합니다:
# deploy.sh의 핵심 부분TASKS=("script:03-connect-service-to-alb.sh"# ECS 서비스를 ALB에 연결"python:update_alb_status.py"# ALB 상태를 module3-config.json에 업데이트)
주요 단계:
03-connect-service-to-alb.sh - ECS 서비스를 ALB에 연결
# Connectivity Agent와 동일한 로직# - module3-config.json에서 설정 로드# - 보안 그룹 업데이트 (ALB → ECS 10006 포트)# - AZ 정렬 (ALB와 ECS Task가 같은 AZ에 위치)# - Task IP를 Target Group에 등록# - 헬스체크 검증
update_alb_status.py - Python 스크립트로 ALB 상태 업데이트
# module3-config.json에 Performance ALB 정보 저장config['performance_alb']={'dns_name': alb_dns_name,'arn': alb_arn,'target_group_arn': target_group_arn}
Connectivity Agent와의 차이점:
Connectivity: 1개 스크립트만 실행 (03-connect-service-to-alb.sh)
Performance: 2단계 실행 (bash → python) — ALB 상태를 config에 저장하는 단계가 추가됨
이 단계는 완료하는 데 약 1-2분이 소요됩니다.
A2A Performance 배포
검증
모든 구성 요소가 제대로 작동하는지 확인하려면 다음 명령어를 실행합니다:
A2A Performance 검증
선택 사항: 콘솔 기반 검증: ECS로 이동하여 a2a-agents-cluster를 확인함으로써 AWS 콘솔을 통해서도 배포를 확인할 수 있습니다.
코드 분석: Performance Agent
요청 흐름: 2개의 컨테이너와 Lambda 연결
Performance Agent 시스템은 2개의 서로 다른 컨테이너로 구성됩니다. 이 단계에서 배포하는 것은 ① A2A Server(ECS)이며, ② AgentCore Runtime(microVM)은 단계 1에서 확인한 사전 프로비저닝된 에이전트입니다.
① A2A Server (ECS) — 프로토콜 변환만 담당
이 단계에서 배포하는 ECS 컨테이너입니다. Lambda를 직접 호출하지 않습니다.
② AgentCore Runtime (microVM) — 에이전트 실행 + Lambda 호출
단계 1에서 확인한 a2a_performance_agent_runtime입니다. BedrockAgentCoreApp()으로 시작합니다.
계층별 역할 정리
계층
코드
역할
A2A Server (ECS)
agent_executer.py
A2A 프로토콜 수신 → OAuth 토큰 획득 → AgentCore API 호출
AgentCore Runtime (microVM)
main.py → agent.py
BedrockAgentCoreApp으로 요청 수신 → PerformanceAgent 생성
MCP Gateway
AWS 관리형
MCPClient가 연결 → Lambda 도구 목록 제공 및 호출 중계
Lambda 도구
lambda_function.py
실제 네트워크 분석 실행 (Flow Monitor, Traffic Mirroring, TCP 수정)
핵심 포인트: ECS의 A2A Server는 프로토콜 변환기일 뿐, Lambda를 직접 호출하지 않습니다. Lambda 호출은 AgentCore Runtime 안의 PerformanceAgent가 MCP Gateway를 통해 수행합니다. 이 구조 덕분에 A2A 프로토콜 계층과 에이전트 로직이 완전히 분리됩니다.
아래에서는 Performance Agent의 시스템 프롬프트와 Lambda 도구의 구조를 살펴봅니다.
참고: Performance Agent의 Lambda 함수(/workspace/workshop-module-3/agentcore-performance-agent/prerequisite/lambda-performance/python/lambda_function.py)는 4,139줄로 워크샵에서 가장 복잡한 코드입니다. PerformanceAnalyzer 클래스가 모든 분석 로직을 캡슐화하고, lambda_handler는 MCP 프로토콜 요청을 라우팅하는 역할만 합니다.
A2A Agent Card 설정 (config.yaml)
Agent Card (필수): A2A 프로토콜에서 에이전트의 "명함" 역할을 하는 필수 구성 요소입니다.
표준 경로: /.well-known/agent-card.json (A2A 프로토콜 표준)
Performance Agent 특징:
Connectivity Agent보다 더 많은 태그 (vpc-flow-logs, traffic-mirroring, tcp-analysis)
포트 10006 사용 (Connectivity는 10003)
역할: Collaborator Agent가 성능 분석 작업이 필요할 때 이 Agent를 선택
Agent Card가 없으면 Collaborator Agent가 해당 에이전트를 발견하거나 사용할 수 없습니다.
# agentcore-performance-agent/main.py
app = BedrockAgentCoreApp()
@app.entrypoint
async def invoke(payload, context):
# PerformanceAgent 생성 → 내부에서 MCP Gateway 연결
agent_task(user_message=payload["prompt"], ...)
# agentcore-performance-agent/agent_config/agent.py
class PerformanceAgent:
def __init__(self, bearer_token, ...):
# MCP Gateway에 연결 → Lambda 도구 목록 로드
gateway_url = get_ssm_parameter("/a2a/app/performance/agentcore/gateway_url")
self.gateway_client = MCPClient(
lambda: streamablehttp_client(gateway_url, headers={"Authorization": f"Bearer {bearer_token}"})
)
self.gateway_client.start()
mcp_tools = self.gateway_client.list_tools_sync() # Lambda 도구가 여기서 로드됨
self.tools.extend(mcp_tools)
# Strands Agent에 도구 등록 → LLM이 자율적으로 선택·호출
self.agent = Agent(model=self.model, tools=self.tools, ...)
# agentcore-performance-agent/agent_config/agent.py
class PerformanceAgent:
system_prompt = """
You are a NetOps Performance Analysis AI assistant.
IMPORTANT CONFIGURATION:
- DEFAULT REGION: "us-east-1"
- SESSION AWS ACCOUNT: 자동 감지 (STS)
- NEVER ask users for region or account ID — 기본값 사용
- IMMEDIATELY proceed with analysis
"""
class PerformanceAnalyzer:
"""AWS 네트워크 성능 분석 엔진"""
async def analyze_network_flow_monitor(self, region, account_id): # Line 1408
"""모든 Network Flow Monitor의 건강 상태 및 트래픽 메트릭 분석"""
# _get_monitor_metrics()로 개별 모니터 메트릭 수집
# data_transferred, retransmissions, RTT 등 반환
async def analyze_traffic_mirroring_logs(self, s3_bucket_name): # Line 1997
"""S3에서 PCAP 파일 추출 후 tshark로 심층 분석"""
# SSM으로 TrafficMirroringTargetInstance에서 tshark 실행
# TCP 재전송, RST/FIN 플래그, 지연 시간 분석
async def fix_retransmissions(self, instance_id, stack_name): # Line 2365
"""TCP 재전송 문제 자동 수정"""
# TCP 버퍼 크기 최적화 (128MB)
# Window Scaling 활성화
# tc qdisc 네트워크 장애 제거
# a2a-performance-agent/config.yaml
agent_metadata:
name: Performance_Agent
description: "Routes requests to a Bedrock AgentCore runtime that analyzes
AWS network performance issues, sets up monitoring infrastructure, and
provides insights from VPC Flow Logs, CloudWatch metrics, and traffic analysis"
capabilities:
push_notifications: true
streaming: true
version: 1.0.0
agent_skills:
- id: analyze_network_performance
name: "Network Performance Analysis"
description: "Analyzes AWS network performance issues including VPC Flow Logs,
CloudWatch metrics, traffic mirroring, TCP performance, and network flow monitoring"
tags:
- performance
- network-monitoring
- vpc-flow-logs
- traffic-mirroring
- tcp-analysis
- cloudwatch-metrics
server:
default_port: 10006