-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Slow upload speed for http server #13608
Comments
Please include your |
This is my simple test
|
Then I test uploading of 1G file multiple times I see performance degrades. |
Duplicate of #10157? |
@kitsonk Maybe - I have some stuff to do on Monday, but I'll try to investigate this on Tuesday. |
@devalexqt So I can reproduce Deno being slower than Node here, but not catastrophically slower like your benchmark suggests. I measured 1GB uploads to the Node server at 1.24 secs, and the Deno upload at 3.40 secs. I am using your exact script and commands, except that I am writing to /tmp instead of cwd. Is there anything else I should know to be able to reproduce your results? What Deno version are you on? |
Try to upload 1g file multiple times in the row, every time it's slower and slower... 2x-3x slower that node, looks catastrophic in my eyes, something wrong in deno code under the hood. I'm using latest deno version, and node 16. Also, I had 2 cpu and 2g ram server. |
I'll try that, thanks.
I agree it isn't great, but 5s is much faster than 5 minutes (60x faster) 😅
Ah, I think this may be related. I'll take this into account. |
Deno also uses almost all CPU resource during upload 1G file. |
Any news? |
No. |
We've recently added the ability to use Web Streams directly with file system files. https://deno.com/blog/v1.19#files-network-sockets-and-stdio-are-now-native-web-streams @devalexqt I'd be interested to see your benchmark again with this new interface: async function handler(req) {
console.log(`>>>new request: ${req.method}, ${req.url}, path: ${req.pathname} params: ${req.searchParams}`)
console.log("HEADERS:",req.headers)
if (req.body) {
console.log("==>hasBody!");
const file = await Deno.create(path.join(config.upload_dir, "native_deno.bin"))
await req.body.pipeTo(file.writable)
}
console.log(">>upload complete!")
return new Response("upload complete!");
} |
Thanks, will try today. |
Hi!
I tested 1G file uploading and with new version total uploading time is reduced from 16.5 to 5.3 seconds (3x improvement and result more stable if I repeat test multiple times). But |
Hi! How we can improve it? |
Tested again on new
Deno still 2x slower vs |
Deno still 2x slower vs node : 2.3sec vs 5.5sec |
Tested new
Deno is slightly faster than previous version 4.5s, but still 2x slower than |
Same results as before...
|
Same result as before....
|
Same result as before....
|
Same result as before....
|
Same result as before....
|
We are actively working on improving performance of HTTP server. |
I'm tested same server but with new
|
Same slow results.
|
ReadableStreams are quite slow as compared to the old Reader/Writer interface, because the buffer is not being reused. Allocating a new Lines 383 to 390 in d7b27ed
By reusing the buffer (not using ReadableStream) uploading a 2gb file takes around 3 seconds, the same upload using a ReadableStream takes 4.8 seconds on my computer. I love having spec compliant The same bottleneck happens in |
I'm working on this, I'll try to have a PR by tomorrow. |
Xref #16046 |
Same slow results.
|
On Windows, the gap between deno and node is getting closer.
|
Little bit faster but still 2x slower vs node.
|
Hi, any update? |
Same slow results... |
How it compared with Bun?
…On Wed, Jan 18, 2023, 17:12 devalexqt ***@***.***> wrote:
deno 1.29.4 (release, x86_64-unknown-linux-gnu)
std 0.173.0
Same slow results...
—
Reply to this email directly, view it on GitHub
<#13608 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJZVS2VOV3XINOIM27NZQLWS66XLANCNFSM5NVO2WJQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
What's the current code you're running by the way? I think |
I tested this with the
EDIT: Never mind, you were already using the new APIs so it seems like my results are not in line with what you see. After some more tinkering I got a 512M buffer sent over taking 4687 ms on the browser from start to finish, and 2947 ms on Deno end to save the file (including file open), so that seems to be more in line with what @devalexqt has been seeing. |
Profiling can be done by setting up the server from the topic statement (change to use I'll come back with a proper profiling code and setup later today. |
Here's the way I profiled this: // test.ts
import { dirname, fromFileUrl, join } from "https://deno.land/std/path/mod.ts";
const directory = dirname(fromFileUrl(import.meta.url));
Deno.serve(async (req) => {
console.group("Request to", req.method, req.url);
console.log(`Headers:`, req.headers);
if (req.body) {
console.log("Initiating upload");
const start = performance.now();
const file = await Deno.open(join(directory, "native_deno.bin"), {
create: true,
write: true,
});
await req.body.pipeTo(file.writable);
console.log("Finished upload in", performance.now() - start, "ms");
}
console.groupEnd();
return new Response();
}); And start the server with Create a 1 GB file with truncate -s 1G foo1GB.bin then start a Performance recording in debugger and send the file to the server with time curl -H "Content-Type:application/octet-stream" -XPOST -T foo1G.bin http://127.0.0.1:8000 Side note about profiling performance:Locally currently when I do not have a debugger connected, the 1GB upload finishes in just about a second. When I connected a debugger but do not start up a performance recording, the upload takes anything from 3.5 to more than 4 seconds. If I start a performance recording, the upload again goes down to about a second. |
Any update? |
Upload 1G file: (This is test for 4 core VPS server)
1.5X slower |
ref: #19737 |
I tested upload speed for varius file sizes: 10M, 100M, 1000M in comparison of
node.js
upload speed inDeno
is about 2x-3x slower and on 1G file deno is 10x slower and use almost all CPU resources (my ubuntu 20.04 vps server has 2 cpu cores and 2G ram).What I'm doing wrong or how to improve upload speed??
Send test data to server(localhost) via curl:
Test file for uploading was created by command:
Results:
I repeat upload test multiple times and every time on 1G file
deno
server become slower and slower (for 10M and 100M test file I don't see any performance reduction) butnode
server upload time stay the same avery time.The text was updated successfully, but these errors were encountered: