Questo contenuto non è disponibile nella lingua selezionata.

13.4.4. Scaling Action Hooks


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.rbchmod +x App_Name/.openshift/action_hooks/haproxy_ctld.rbchmod +x App_Name/.openshift/action_hooks/haproxy_ctld.rb
    Copy to Clipboard Toggle word wrap
  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
Copy to Clipboard Toggle word wrap
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat