# shared-cpu-1x performance on CPU bound tasks

**URL:** <https://community.fly.io/t/shared-cpu-1x-performance-on-cpu-bound-tasks/1293>\
**Category:** Questions / Help\
**Created:** [April 27, 2021, 8:55pm UTC](https://community.fly.io/t/shared-cpu-1x-performance-on-cpu-bound-tasks/1293 "2021-04-27T20:55:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![friz](https://avatars.discourse-cdn.com/v4/letter/f/c77e96/32.png) [@friz](https://community.fly.io/u/friz)\
**Post date:** [April 27, 2021, 8:55pm UTC](https://community.fly.io/t/shared-cpu-1x-performance-on-cpu-bound-tasks/1293/1 "2021-04-27T20:55:54Z")

</div>

Hi All,

I am an MSc student currently writing his master’s thesis.  
In the process I measured the execution time of Java workloads on different FaaS(-like) platforms from within the code. Though Fly generally compared favorably to other platforms, it completely surpassed my expectations on a simple CPU bound workload. Fly was able to finish a prime number calculation by unoptimized trial division in less than half the time AWS Lambda (or our own server) needed. Since the code and resource allocation were as similar as possible, I didn’t expect such a huge difference.

I tried to investigate the cause, but didn’t find a satisfying explanation, so I would be very thankful if I could get a short statement on this to include in my thesis.

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [April 27, 2021, 10:36pm UTC](https://community.fly.io/t/shared-cpu-1x-performance-on-cpu-bound-tasks/1293/2 "2021-04-27T22:36:43Z")

</div>

Well that’s super cool!

The results you got are probably a combo of a few things. We run VMs on big, beefy boxes with AMD Epyc CPUs. Most of the hardware has 24 cores /48 threads, some has 32c / 64t. We provision up to 8 or 16 VMs per core, if they were all blasting the CPU you’d get worse performance.

Most VMs aren’t CPU bound, so your VM will most likely get scheduled on a hardware thread that’s close to idle.

---

<div class="post-metadata">

**Author:** ![Kikobeats](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kikobeats/32/37710_2.png) [@Kikobeats](https://community.fly.io/u/Kikobeats)\
**Post date:** [April 28, 2021, 8:29am UTC](https://community.fly.io/t/shared-cpu-1x-performance-on-cpu-bound-tasks/1293/3 "2021-04-28T08:29:17Z")

</div>

@kurt just curiosity, but any reason to don’t offer `shared-cpu-2x`?

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [April 28, 2021, 3:35pm UTC](https://community.fly.io/t/shared-cpu-1x-performance-on-cpu-bound-tasks/1293/4 "2021-04-28T15:35:15Z")

</div>

It’s been #2 on the priority list for at least two months now. 🙂

We plan to offer up to shared-cpu-8x someday.

---

<div class="post-metadata">

**Author:** ![friz](https://avatars.discourse-cdn.com/v4/letter/f/c77e96/32.png) [@friz](https://community.fly.io/u/friz)\
**Post date:** [April 28, 2021, 8:35pm UTC](https://community.fly.io/t/shared-cpu-1x-performance-on-cpu-bound-tasks/1293/5 "2021-04-28T20:35:00Z")

</div>

@kurt Thank you for your quick reply.

---

<div class="post-metadata">

**Author:** ![george](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@george](https://community.fly.io/u/george)\
**Post date:** [August 24, 2021, 7:46pm UTC](https://community.fly.io/t/shared-cpu-1x-performance-on-cpu-bound-tasks/1293/6 "2021-08-24T19:46:07Z")

</div>

> [@kurt](#):
>
> We provision up to 8 or 16 VMs per core, if they were all blasting the CPU you’d get worse performance.
> 
> Most VMs aren’t CPU bound, so your VM will most likely get scheduled on a hardware thread that’s close to idle.

That said, is there a minimum CPU resource guarantee in a worst case scenario (i.e. the other 15 VMs are blasting the CPU)?

We have an I/O bound task (nginx serving static files) and were thinking if a pool of shared-cpu-1x instances could work reliably for our case (sustained load of 300-500 requests per second).

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [August 24, 2021, 7:48pm UTC](https://community.fly.io/t/shared-cpu-1x-performance-on-cpu-bound-tasks/1293/7 "2021-08-24T19:48:44Z")

</div>

Yeah we’re using cgroups + consistent fair scheduling. If all the VMs on a host are running prime number generators, a `shared-cpu-1x` vm will effectively get 1/15th of a physical hardware thread. This is a very theoretical case, though, we’re likely to shuffle VMs around long before that happens.

`shared-cpu-1x` servers will work great for nginx, though, we have a bunch of people doing exactly that.

---

<div class="post-metadata">

**Author:** ![Whistler](https://avatars.discourse-cdn.com/v4/letter/w/a3d4f5/32.png) [@Whistler](https://community.fly.io/u/Whistler)\
**Post date:** [August 2, 2022, 8:56am UTC](https://community.fly.io/t/shared-cpu-1x-performance-on-cpu-bound-tasks/1293/8 "2022-08-02T08:56:13Z")

</div>

@kurt - any news re: `shared-cpu-2x` - `shared-cpu-8x` for 2022?
