英文:
Spring Boot server realistic multipart up/download speed of large (~1GB) files?
问题
我正在开发一个处理通过多部分方式通过HTTP上传和下载大型(约1GB)文件的Spring Boot服务器。我通过spring.servlet.multipart.enabled=false
禁用了Spring的默认多部分过滤器,并且使用Apache FileUpload流式API来处理HTTP请求。
当我同时开始上传(来自Postman)或下载(来自浏览器)时,我获得的最大总速度约为40MB/s。瓶颈似乎是CPU,因为在40MB/s的速度下,CPU利用率约为100%(所有核心)。
我尝试通过在上传@Controller
后面的@Service
中丢弃传入的HTTP多部分InputStream来对上传进行分析,但40MB/s的限制并没有变快。(我的意思是丢弃我读取的流,但没有将其转发到文件或其他任何地方。基本上只是跳过了流。)
我在**Intel i7-6700HQ处理器(4核8线程~3GHz)**上获得上述性能。
我想知道我是否搞错了什么,或者这是否是使用Spring Boot的限制?我该如何提高性能? Spring Boot对于这个任务来说是否是一个不好的选择?
(如果您想查看源代码,可以在这里找到:https://github.com/janosgats/laboschqpa.filehost)
英文:
I'm working on a Spring Boot server which handles up & downloads of large (~1GB) files by multipart via HTTP. I disabled Spring's default multipart filter (by spring.servlet.multipart.enabled=false
) and use Apache FileUpload Streaming API to process the HTTP request.
When I start simultaneous uploads (from postman) or downloads (from browser) I get the max sum speed of about 40MB/s. The bottleneck looks to be the CPU, since it's ~100% utilized (all cores) at 40MB/s speed.
I tried to profile uploads by discarding the incoming HTTP multipart InputStream in the @Service
behind the upload @Controller
, but the 40MB/s limit didn't get faster. (I mean discarding that I read out the stream but didn't forward it into a file or anything else. So basically just skipped the stream.)
I get the above performance on an Intel i7-6700HQ processor (4 cores 8 threads ~ 3GHz).
I want to know if I messed up something OR is this the limitation of using Spring Boot? How could I improve performance? Is Spring Boot a bad choice for this task?
(Here you can see the source code, if you would take a look at it: https://github.com/janosgats/laboschqpa.filehost)
专注分享java语言的经验与见解,让所有开发者获益!
评论