# High(er) CPU utilization with 'socket' backend (esp. for UDP)

**URL:** <https://erlangforums.com/t/high-er-cpu-utilization-with-socket-backend-esp-for-udp/1720>\
**Category:** Questions / Help\
**Tags:** erlang-otp\
**Created:** [August 4, 2022, 2:42pm UTC](https://erlangforums.com/t/high-er-cpu-utilization-with-socket-backend-esp-for-udp/1720 "2022-08-04T14:42:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![holger](https://erlangforums.com/user_avatar/erlangforums.com/holger/32/831_2.png) [@holger](https://erlangforums.com/u/holger)\
**Post date:** [August 4, 2022, 2:42pm UTC](https://erlangforums.com/t/high-er-cpu-utilization-with-socket-backend-esp-for-udp/1720/1 "2022-08-04T14:42:47Z")

</div>

When using `{inet_backend, socket}` for `gen_tcp` sockets, I see significantly higher CPU utilization than with `{inet_backend, inet}`, and even more so for `gen_udp`, on both OTP 24 and 25. I did no proper measurements so far, but for an application that doesn’t do much besides forwarding TCP/UDP packets using `{active, 100}` mode, a network load that produced around 5% CPU usage with `inet` ended up with around 15% CPU usage with `socket`.

This was just a quick experiment and I didn’t investigate yet (except for a very quick look at profiling numbers, which showed message passing at the top in both cases). Just curious whether others have seen similar results, or the opposite, or whether that might even be expected for some reason?

---

<div class="post-metadata">

**Author:** ![mpope](https://erlangforums.com/letter_avatar_proxy/v4/letter/m/71c47a/32.png) [@mpope](https://erlangforums.com/u/mpope)\
**Post date:** [August 11, 2022, 1:47am UTC](https://erlangforums.com/t/high-er-cpu-utilization-with-socket-backend-esp-for-udp/1720/2 "2022-08-11T01:47:12Z")

</div>

Some recent measurements I’ve done with OTP 24 + inet vs socket show similar CPU usage. My test workload was different though. I was measuring memory / CPU usage for moving 1 - 4GB of data between a client and a cloud storage account with an Erlang application in the middile.

While CPU usage was similar, memory usage shifted quite a bit. Incoming data consumed more memory after switching to socket. On the inet backend outgoing memory usage was higher.
