Saltar al contenido

Configuración de Flogo: ¿Cómo dominarla en 5 minutos?

Flogo Enterprise es una plataforma excelente para construir tus microservicios y, desde el principio, vas a alcanzar un número de rendimiento increíble.

Pero, incluso con eso, estamos trabajando en un mundo donde cada milisegundo cuenta y cada MB de memoria cuenta, por lo que es importante conocer las herramientas que tenemos en nuestras manos para ajustar a un nivel más fino nuestra aplicación Flogo Enterprise.

Como ya sabes, Flogo está construido sobre el lenguaje de programación Go, por lo que vamos a diferenciar los parámetros que pertenecen al propio lenguaje de programación, y luego otros parámetros que son específicos de Flogo.

Todos estos parámetros deben definirse como variables de entorno, por lo que la forma de aplicarlos dependerá de cómo configures las variables de entorno en tu propia plataforma de destino (Windows, Linux, OSX, Docker, etc…)

Parámetros Específicos de Flogo OSS

Puedes consultar todos los parámetros y sus valores predeterminados en la documentación de Flogo:

Configuraciones Relacionadas con el Rendimiento

  • FLOGO_LOG_LEVEL: Permite establecer a nivel de inicio el nivel de registro que deseas usar para la ejecución de la aplicación. El valor predeterminado está configurado en «INFO» y se puede aumentar a DEBUG para realizar algunos diagnósticos o análisis adicionales y configurar en «WARN» o «ERROR» para aplicaciones de producción que necesitan el máximo rendimiento evitando imprimir trazas adicionales.
  • FLOGO_RUNNER_TYPE: Permite establecer a nivel de inicio el tipo de corredor y el valor predeterminado es POOLED.
  • FLOGO_RUNNER_WORKERS: Permite establecer a nivel de inicio el número de trabajadores de Flogo que van a ejecutar la lógica. El valor predeterminado es 5 y se puede aumentar cuando estás ejecutando en hardware potente que tiene mejores capacidades de paralelismo.
  • FLOGO_RUNNER_QUEUE: Permite configurar a nivel de inicio el tamaño de la cola del corredor que va a mantener en memoria las solicitudes que van a ser manejadas por los trabajadores. El valor predeterminado es 50 y cuando el número es alto también será alto el consumo de memoria, pero el acceso de los trabajadores a la tarea será más rápido.

Otras Configuraciones

  • FLOGO_CONFIG_PATH: Establece la ruta del archivo JSON de configuración que se va a usar para ejecutar la aplicación en caso de que no esté incrustado en el propio binario. El valor predeterminado es flogo.json
  • FLOGO_ENGINE_STOP_ON_ERROR: Establece el comportamiento del motor cuando ocurre un error interno. Por defecto está configurado en true y significa que el motor se detendrá tan pronto como ocurra el error.
  • FLOGO_APP_PROP_RESOLVERS: Establece cómo se van a recopilar las propiedades de la aplicación para ser utilizadas. El valor es el resolvedor de propiedades a usar en tiempo de ejecución. Por defecto es None y se incluye información adicional en la sección de documentación de propiedades de la aplicación.
  • FLOGO_LOG_DTFORMAT: Establece cómo se van a mostrar las fechas en las trazas de registro. El valor predeterminado es «2006–01–02 15:04:05.000».

Parámetros Específicos de Flogo Enterprise

Incluso cuando todas las propiedades de Project Flogo son compatibles con Flogo Enterprise, la versión empresarial incluye propiedades adicionales que se pueden usar para establecer comportamientos adicionales del motor.

FLOGO_HTTP_SERVICE_PORT: Esta propiedad establece el puerto donde se alojarán los puntos finales internos. Este punto final interno se utiliza para el punto final de verificación de estado, así como para la exposición de métricas y cualquier otro acceso interno que proporcione el motor.

FLOGO_LOG_FORMAT: Esta propiedad nos permite definir el formato de notación para nuestras trazas de registro. TEXT es el valor predeterminado, pero podemos usar JSON para que nuestras trazas se generen en JSON, por ejemplo, para ser incluidas en algún tipo de plataforma de ingestión de registros.

Parámetros Específicos del Lenguaje de Programación Go

  • GOMAXPROCS: Limita el número de hilos del sistema operativo que pueden ejecutar código Go a nivel de usuario simultáneamente. No hay límite para el número de hilos que pueden estar bloqueados en llamadas al sistema en nombre del código Go; esos no cuentan contra el límite de GOMAXPROCS.
  • GOTRACEBACK: Controla la cantidad de salida generada cuando un programa Go falla debido a un pánico no recuperado o una condición de tiempo de ejecución inesperada. Por defecto, un fallo imprime una traza de pila para la goroutine actual, omitiendo funciones internas del sistema de tiempo de ejecución y luego sale con el código de salida 2. El fallo imprime trazas de pila para todas las goroutines si no hay una goroutine actual o el fallo es interno al tiempo de ejecución. GOTRACEBACK=none omite completamente las trazas de pila de goroutine. GOTRACEBACK=single (el valor predeterminado) se comporta como se describe arriba. GOTRACEBACK=all agrega trazas de pila para todas las goroutines creadas por el usuario. GOTRACEBACK=system es como «all» pero agrega marcos de pila para funciones de tiempo de ejecución y muestra goroutines creadas internamente por el tiempo de ejecución. GOTRACEBACK=crash es como «system» pero falla de una manera específica del sistema operativo en lugar de salir.
  • GOGC: Establece el porcentaje objetivo inicial de recolección de basura. Se activa una recolección cuando la proporción de datos recién asignados a datos vivos restantes después de la recolección anterior alcanza este porcentaje. El valor predeterminado es GOGC=100. Configurar GOGC=off desactiva completamente el recolector de basura.
Etiquetas:

Flogo Configuration: How To Master It In 5 Minutes?

Flogo Enterprise is so great platform to build your microservices and Out of the box, you’re going to reach an incredible performance number.

But, even with that, we’re working in a world where each milliseconds count and each memory MB count so it is important to know the tools that we have in our hands to tune at a finer-grained level our Flogo Enterprise application.

As you already know, Flogo is built in top of Go programing language, so we are going to differentiate the parameters that belong to the programing language itself, then other parameters that are Flogo specifics.

All these parameters have to be defined as environment variables, so the way to apply these are going to rely on how you set environment variables in your own target platform (Windows, Linux, OSX, Docker, etc…)

Flogo OSS Specific Parameters

You can check all the parameters and it is default values at the Flogo documentation:

Performance Related Settings

  • FLOGO_LOG_LEVEL: Allows to set at start-up level the log level you want to use for the application execution. The default value is set to “INFO” and it can be increased to DEBUG to do some additional troubleshooting or analysis and set to “WARN” or “ERROR” for production applications that need most performance avoiding printing additional traces.
  • FLOGO_RUNNER_TYPE: Allows to set at the start-up level the type of the runner and the default value is POOLED.
  • FLOGO_RUNNER_WORKERS: Allows to set at the start-up level the number of Flogo workers that are going to be executing logic. The default value is 5 and can be increased when you’re running on powerful hardware that has better parallelism capabilities.
  • FLOGO_RUNNER_QUEUE: Allows to set up at the start-up level the size of the runner queue that is going to keep in memory the requests that are going to be handled by the workers. The default value is 50 and when the number is high it will be also high the memory consumption but the access form the workers to the task will be faster.

Other Settings

  • FLOGO_CONFIG_PATH: Sets the path of the config JSON file that is going to be used to run the application in case it is not embedded in the binary itself. The default value is flogo.json
  • FLOGO_ENGINE_STOP_ON_ERROR: Set the behavior of the engine when an internal error occurs. By default is set to true and means that engine will stop as soon as the error occurs.
  • FLOGO_APP_PROP_RESOLVERS: Set how application properties are going to be gathered for the application to be used. The value is property resolver to use at runtime. By default is None and additional information is included in application properties documentation section.
  • FLOGO_LOG_DTFORMAT: Set how the dates are going to be displayed in the log traces. The default value is “2006–01–02 15:04:05.000”.

Flogo Enterprise Specific Parameters

Even when all the Project Flogo properties are supported by Flogo Enterprise, the enterprise version includes additional properties that can be used to set additional behaviors of the engine.

FLOGO_HTTP_SERVICE_ PORT: This property set the port where the internal endpoints will be hosted. This internal endpoint is used for healthcheck endpoint as well as metrics exposition and any other internal access that is provided by the engine.

FLOGO_LOG_FORMAT: This property allows us to define the notation format for our log traces. TEXT is the default value but we can use JSON to make our traces to be generated in JSON, for example, to be included in some kind of logging ingestion platform

Go Programing Language Specific Parameters

  • GOMAXPROCS: Limits the number of operating system threads that can execute user-level Go code simultaneously. There is no limit to the number of threads that can be blocked in system calls on behalf of Go code; those do not count against the GOMAXPROCS limit.
  • GOTRACEBACK: Controls the amount of output generated when a Go program fails due to an unrecovered panic or an unexpected runtime condition. By default, a failure prints a stack trace for the current goroutine, eliding functions internal to the run-time system and then exits with exit code 2. The failure prints stack traces for all goroutines if there is no current goroutine or the failure is internal to the run-time. GOTRACEBACK=none omits the goroutine stack traces entirely. GOTRACEBACK=single (the default) behaves as described above. GOTRACEBACK=all adds stack traces for all user-created goroutines. GOTRACEBACK=system is like “all” but adds stack frames for run-time functions and shows goroutines created internally by the run-time. GOTRACEBACK=crash is like “system” but crashes in an operating system-specific manner instead of exiting.
  • GOGC: Sets the initial garbage collection target percentage. A collection is triggered when the ratio of freshly allocated data to live data remaining after the previous collection reaches this percentage. The default is GOGC=100. Setting GOGC=off disables the garbage collector entirely.
Etiquetas: