Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM][AWS] incorrect calculation of estimated cost and compute useg #146206

Closed
cauemarcondes opened this issue Nov 23, 2022 · 1 comment · Fixed by #146328
Closed

[APM][AWS] incorrect calculation of estimated cost and compute useg #146206

cauemarcondes opened this issue Nov 23, 2022 · 1 comment · Fixed by #146328
Assignees
Labels
apm:test-plan-regression bug Fixes for quality problems that affect the customer experience Team:APM - DEPRECATED Use Team:obs-ux-infra_services. v8.6.0

Comments

@cauemarcondes
Copy link
Contributor

@AlexanderWert reported that the current way we calculate the estimated cost and compute usage is correct as long as the memory size doesn't change when we have multiple invocations.

Here's the example he gave me assuming we have three invocations:

(1) computeUsage = (totalMemory[1] * billedDuration[1]) + (totalMemory[2] * billedDuration[2]) + (totalMemory[3] * billedDuration[3])

What we currently do is:

avgTotalMemory = (totalMemory[1] + totalMemory[2] + totalMemory[3]) / 3
avgBilledDuration = (billedDuration[1] + billedDuration[2] + billedDuration[3]) / 3
(2) computeUsage = avgTotalMemory * avgBilledDuration * 3 

(1) is mathematically NOT the same as (2) if total memory is not the same value in all invocations.

How to fix it:

We must calculate the compute usage per invocation and sum the result afterward.

@cauemarcondes cauemarcondes added bug Fixes for quality problems that affect the customer experience apm:test-plan-regression v8.6.0 labels Nov 23, 2022
@botelastic botelastic bot added the needs-team Issues missing a team label label Nov 23, 2022
@cauemarcondes cauemarcondes self-assigned this Nov 23, 2022
@ppisljar ppisljar added the Team:APM - DEPRECATED Use Team:obs-ux-infra_services. label Nov 24, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:APM)

@botelastic botelastic bot removed the needs-team Issues missing a team label label Nov 24, 2022
cauemarcondes added a commit that referenced this issue Nov 29, 2022
closes #146206

**Before** we were averaging the memory and billed duration and then we
calculated the compute usage.
**Now** We first calculate the compute usage then get the average and
then convert to GB-Sec.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Nov 29, 2022
closes elastic#146206

**Before** we were averaging the memory and billed duration and then we
calculated the compute usage.
**Now** We first calculate the compute usage then get the average and
then convert to GB-Sec.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 9cadd36)
kibanamachine referenced this issue Nov 29, 2022
# Backport

This will backport the following commits from `main` to `8.6`:
- [[APM][AWS] fix compute usage calc
(#146328)](#146328)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Cauê
Marcondes","email":"55978943+cauemarcondes@users.noreply.github.com"},"sourceCommit":{"committedDate":"2022-11-29T09:42:59Z","message":"[APM][AWS]
fix compute usage calc (#146328)\n\ncloses
https://github.com/elastic/kibana/issues/146206\r\n\r\n**Before** we
were averaging the memory and billed duration and then we\r\ncalculated
the compute usage.\r\n**Now** We first calculate the compute usage then
get the average and\r\nthen convert to GB-Sec.\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"9cadd361ded281514626db5d0d49154a62d7484a","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:APM","release_note:skip","v8.6.0","v8.7.0"],"number":146328,"url":"https://github.com/elastic/kibana/pull/146328","mergeCommit":{"message":"[APM][AWS]
fix compute usage calc (#146328)\n\ncloses
https://github.com/elastic/kibana/issues/146206\r\n\r\n**Before** we
were averaging the memory and billed duration and then we\r\ncalculated
the compute usage.\r\n**Now** We first calculate the compute usage then
get the average and\r\nthen convert to GB-Sec.\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"9cadd361ded281514626db5d0d49154a62d7484a"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146328","number":146328,"mergeCommit":{"message":"[APM][AWS]
fix compute usage calc (#146328)\n\ncloses
https://github.com/elastic/kibana/issues/146206\r\n\r\n**Before** we
were averaging the memory and billed duration and then we\r\ncalculated
the compute usage.\r\n**Now** We first calculate the compute usage then
get the average and\r\nthen convert to GB-Sec.\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"9cadd361ded281514626db5d0d49154a62d7484a"}}]}]
BACKPORT-->

Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:test-plan-regression bug Fixes for quality problems that affect the customer experience Team:APM - DEPRECATED Use Team:obs-ux-infra_services. v8.6.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants