Pesquisar

Este conteúdo não está disponível no idioma selecionado.

13.4.4. Scaling Action Hooks

download PDF
Automatic scaling is controlled by the haproxy_ctld daemon. The haproxy_ctld.rb script, which changes the thresholds and algorithms used to control scale up and down behavior, can be customized for use as an action hook in scalable applications.

Procedure 13.3. To Customize Automatic Scaling for an Application:

  1. Use SSH to connect to a scalable application and consult the generic ~/haproxy/usr/bin/haproxy_ctld.rb script for detailed usage information.
  2. Copy the file to the Git repository of the application in the App_Name/.openshift/action_hooks/ directory.
  3. Ensure the file is executable:
    # chmod +x App_Name/.openshift/action_hooks/haproxy_ctld.rb
  4. Edit the file to the desired specifications.
  5. Deploy the changes. To ensure that the changes take effect immediately, the HAProxy cartridge restarts automatically during deployment if the haproxy_ctld.rb action hook is detected.

Example 13.2. Scaling Up Based on Memory Usage

To enable auto-scaling based on memory usage, edit the ~/haproxy/usr/bin/haproxy_ctld.rb script by specifying the following parameters.
...
# Scale up when any gear is using 400M or more memory.
mem_scale_up = 419430400

# Scale down when any gear is using 300M or less memory
mem_scale_down = 314572800

# min_gears - Once this number of gears is met, don't try to scale down any lower
min_gears = 2

gear_list['web'].each do |uuid, array|
 mem_usage = `ssh -i ~/.openshift_ssh/id_rsa #{uuid}@#{array['dns']} 'oo-cgroup-read memory.memsw.usage_in_bytes'`.to_i
 if mem_usage >= mem_scale_up
   @log.error("memory usage (#{mem_usage}) on #{array['dns']} is above threshold(#{mem_scale_up}), adding new gear")
   self.add_gear
 end
end
Red Hat logoGithubRedditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja oBlog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

© 2024 Red Hat, Inc.