Files

94 lines
4.3 KiB
TeX

\chapter{Pruebas de estr\'es y carga}
\label{ch:estres}
\section{Herramienta}
Se usa \textbf{k6} (Grafana Labs) contra \texttt{http://127.0.0.1:8189}. Scripts de referencia en \texttt{docs/plan\_pruebas/scripts/}. M\'etricas complementarias: \texttt{docker stats}, \texttt{pg\_stat\_activity}, Redis INFO, logs del gateway.
\section{Perfiles de carga}
Por defecto, en el host de la secci\'on~\ref{sec:host-pruebas}, aplicar el perfil \textbf{host-compartido-8gb}. El perfil \textbf{laboratorio} solo aplica si el Docker Engine est\'a dedicado a IPS (sin MLflow/Airflow/n8n, $\geq$3\,GiB libres).
\begin{table}[ht]
\centering
\begin{tabular}{@{}p{2.3cm}p{5.5cm}p{5.0cm}@{}}
\toprule
\textbf{ID} & \textbf{host-compartido-8gb} & \textbf{laboratorio} \\
\midrule
ST-GW-01 & 5$\rightarrow$15$\rightarrow$25 VUs; p95 $<$500\,ms & 50--100 VUs; p95 $<$300\,ms \\
ST-BOT-01 & 3--8 workers / 8\,s & 20--50 workers / 8\,s \\
ST-BOT-03 & 5--15 VUs events & hasta 40 VUs / 5k events \\
ST-COUNT-01 & 1 rps, max 3--5 VUs; evitar si RAM libre $<$3\,GiB & 5--20 lotes $\times$10 \\
ST-EXT-01 & 20--50 tasks; 1 r\'eplica worker & 100--500 tasks; 2 r\'eplicas \\
\bottomrule
\end{tabular}
\caption{Cargas por perfil de entorno.}
\label{tab:perfiles-carga}
\end{table}
Con el zoo Docker actual (MLflow $\sim$1{,}86\,GiB + Airflow + n8n, etc.) \textbf{no} ejecutar ST-COUNT-01 ni ST-EXT agresivo sin liberar memoria primero.
\section{Escenarios (cat\'alogo completo)}
\begin{table}[ht]
\centering
\small
\begin{tabular}{@{}llll@{}}
\toprule
\textbf{ID} & \textbf{Objetivo} & \textbf{Carga (lab)} & \textbf{Observar / riesgo} \\
\midrule
ST-GW-01 & Gateway concurrente & 50--100 VUs live & p95, 5xx --- orquestaci\'on lenta \\
ST-BOT-01 & Heartbeats masivos & 20--50 workers & Offline falsos --- PCs muertos \\
ST-BOT-02 & Claim contention & 10 workers & Un claim/job --- doble descarga \\
ST-BOT-03 & Event storm & Hasta 5k events & Escritura PG --- perdida eventos \\
ST-BOT-04 & Excel grande & 10--50\,MB & Timeout 600\,s --- upload cortado \\
ST-MINIO-01 & PutObject paralelo & N PCs & Errores S3 --- PDFs perdidos \\
ST-COUNT-01 & OCR paralelo & 5--20 lotes x10 & RAM/OOM --- cuello 100k \\
ST-EXT-01 & Cola ARQ & 100--500 (mock) & Backlog --- workers insuficientes \\
ST-EXT-02 & LLM real & 20--50 PDFs & 429, coste --- cuota LLM \\
ST-DES-01 & Polling desktop & 10 clientes & CPU GW --- UI lenta \\
ST-DB-01 & PG saturaci\'on & Mezcla BOT+EXT & Locks --- deadlocks \\
\bottomrule
\end{tabular}
\caption{Escenarios de estr\'es (objetivo y riesgo).}
\end{table}
\section{Scripts k6 incluidos}
\begin{table}[h]
\centering
\begin{tabular}{@{}llp{4.8cm}@{}}
\toprule
\textbf{Archivo} & \textbf{ID} & \textbf{Target} \\
\midrule
\texttt{k6\_gateway\_health.js} & ST-GW-01 & \texttt{GET /health/live} \\
\texttt{k6\_bot\_heartbeats.js} & ST-BOT-01 & \texttt{POST .../workers/heartbeat} \\
\texttt{k6\_bot\_events.js} & ST-BOT-03 & \texttt{POST .../jobs/\{id\}/events} \\
\texttt{k6\_count\_batches.js} & ST-COUNT-01 & \texttt{POST /count/v1/count} \\
\bottomrule
\end{tabular}
\caption{Mapeo script $\leftrightarrow$ escenario.}
\end{table}
Los scripts aceptan \texttt{PROFILE=shared8g} (default recomendado en este host) o \texttt{PROFILE=lab}.
\section{SLOs de aceptaci\'on}
\subsection{Perfil host-compartido-8gb (default)}
\begin{itemize}
\item Gateway \texttt{/health/live} p95 $<$\,\SI{500}{\milli\second}; error rate $<$\,1\,\%.
\item No usar el health \emph{agregado} (\texttt{/health}) como SLO de latencia (puede superar 10\,s en este host).
\item Heartbeat: 0 workers offline falsos con $\leq$8 workers y poll $\leq$8\,s.
\item Claim: 0 jobs con dos workers en \texttt{RUNNING}.
\item Count-api: sin OOM; detener la prueba si el host entra en swap sostenido.
\end{itemize}
\subsection{Perfil laboratorio}
\begin{itemize}
\item Gateway p95 salud: $<$\,\SI{300}{\milli\second}; error rate $<$\,0,1\,\%.
\item Extracci\'on (LLM mock): backlog ARQ drenado con \texttt{WORKER\_REPLICAS=2}.
\item Count-api: sin OOM en carga acordada; PDFs oversized $\rightarrow$ 4xx.
\end{itemize}
\section{Ejecuci\'on ejemplo}
\begin{lstlisting}[language=bash,caption={Estr\'es gateway en host compartido}]
cd docs/plan_pruebas/scripts
# Documentar entorno: free -h && docker stats --no-stream
k6 run -e BASE_URL=http://127.0.0.1:8189 -e PROFILE=shared8g k6_gateway_health.js
\end{lstlisting}