*/
void server_recalc_eweight(struct server *sv);
+/* returns the current server throttle rate between 0 and 100% */
+static inline unsigned int server_throttle_rate(struct server *sv)
+{
+ struct proxy *px = sv->proxy;
+
+ /* when uweight is 0, we're in soft-stop so that cannot be a slowstart,
+ * thus the throttle is 100%.
+ */
+ if (!sv->uweight)
+ return 100;
+
+ return 100U * (px->lbprm.wmult * sv->eweight + px->lbprm.wdiv - 1) / (px->lbprm.wdiv * sv->uweight);
+}
+
/*
* Parses weight_str and configures sv accordingly.
* Returns NULL on success, error message string otherwise.
chunk_appendf(&trash, "<td colspan=3></td>");
/* throttle */
- if ((sv->state & SRV_WARMINGUP) &&
- now.tv_sec < sv->last_change + sv->slowstart &&
- now.tv_sec >= sv->last_change) {
- chunk_appendf(&trash, "<td class=ac>%d %%</td></tr>\n",
- (int)MAX(1, 100 * (now.tv_sec - sv->last_change) / sv->slowstart));
- }
+ if (sv->state & SRV_WARMINGUP)
+ chunk_appendf(&trash, "<td class=ac>%d %%</td></tr>\n", server_throttle_rate(sv));
else
chunk_appendf(&trash, "<td class=ac>-</td></tr>\n");
}
relative_pid, px->uuid, sv->puid);
/* throttle */
- if ((sv->state & SRV_WARMINGUP) &&
- now.tv_sec < sv->last_change + sv->slowstart &&
- now.tv_sec >= sv->last_change)
- chunk_appendf(&trash, "%d", (int)MAX(1, 100 * (now.tv_sec - sv->last_change) / sv->slowstart));
+ if (sv->state & SRV_WARMINGUP)
+ chunk_appendf(&trash, "%d", server_throttle_rate(sv));
/* sessions: lbtot */
chunk_appendf(&trash, ",%lld,", sv->counters.cum_lbconn);