docker-alpine: Performance of Node.js is quite bad compared to other images
Hi,
We’ve been running Alpine containers in production for over a half year now, but performance of our applications is starting to become a real issue. We’re running Node.js (4.x) on the latest Alpine release (3.3). We are quite happy with Alpine, because of its minimalistic approach, but a little less happy with its performance.
When comparing performance of an Alpine container against another “flavour”, like CentOS or Ubuntu, we were quite shocked; the performance (of this particular script) on Alpine is three times as slow as on other images!
We think this is caused by the fundamental choice of Alpine using “musl libc”, but we’re not sure yet. Can you guys shed some light on this? I haven’t found any other issues about performance being bad when using Alpine, so either we’re the first that encountered this issue, or we’re doing something wrong 😉
The following script we’ve used for testing performance:
var instance = {};
instance.a = 'asdfasdasdf';
instance.b = 'asdfasdasdf';
instance.c = 'asdfasdasdf';
instance.d = 'asdfasdasdf';
instance.e = 'asdfasdasdf';
for (var i = 0; i < 5; i++) {
var instance2 = {};
instance2.a = instance;
instance2.b = instance;
instance2.c = instance;
instance2.d = instance;
instance2.e = instance;
instance2.f = instance;
instance = instance2;
}
var json = JSON.stringify(instance2);
var test;
for (var i = 0; i < 100; i++) {
JSON.parse(json);
for (var j = 0; j < 10000; j++) {
test = test + 'a';
test = test.substring(1, test.length - 1);
}
}
When running “time node app.js” command on an Alpine based image:
real 0m 4.99s user 0m 4.90s sys 0m 0.10s
When running “time node app.js” command on an CentOS based image:
real 0m1.682s user 0m1.596s sys 0m0.092s
Thanks in advance!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 9
- Comments: 20
Alpine uses musl where other images use the more common glibc, so nodejs for alpine is compiled against musl. Not sure if the performance hit is caused by this compile time difference, but it looks to me that it is. We now run nodejs from a centos based image (glibc) that has far better nodejs performance. Not to bash on alpine, but for our usecases it doesn’t work out well.
I tested with void linux, glibc and musl. They should be built with same flags and have same version. Both variants run at ~1.0 sec. So I believe this is not musl libc issue. It has probably more to do with how alpine linux build the package.