<p>I have a web app, having 2 tiers: wordpress as frontend and MySQL as backend.</p>
<p>The frontend is deployed using Helm chart, however the backend is deployed using Operator.</p>
<p>Since my webapp receives a lot of traffic, i would like to implement horizental pod autosacling (HPA).</p>
<p>My Question:
Where can i define HPA: in frontend part (i.e: wordpress level) ?  in backend part (i.e: MySQL level) ? or both ?</p>
<p>Thank you for your help!</p>

Mohamed
<p>You probably can't usefully set up HPA on the database.  MySQL and PostgreSQL are usually single nodes, or if they have multiple nodes, they run in an active/standby mode, so adding nodes won't necessarily add capacity.  (Even with a clustered database, there can be <a href="https://stackoverflow.com/a/62714497">practical problems with setting up HPA around scale-in</a>.)</p>
<p>You can set up HPA on the application.  It's helpful to understand what the limiting factor on your application actually is: if you send enough load that it starts being slow or failing requests, is it starved for CPU time, out of memory, or waiting on the database?  That would affect what parameters you'd want to set on the HPA.</p>
<p>One realistic situation is that your application does some database queries, which take the bulk of the time, and then very quickly renders the data to HTML or JSON.  In this situation it will be hard to take advantage of HPA: the single-node database is hard to scale, and even if you scale up the application pods, you'll still be blocked on database queries.</p>
