Skip to content
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

ServiceComb框架相比于SpringMvc在处理MultipartFile表单文件有什么优化 #4267

Open
xxffzq opened this issue Mar 15, 2024 · 1 comment

Comments

@xxffzq
Copy link

xxffzq commented Mar 15, 2024

代码本来使用了ServiceComb版本2.8.6,切换为SpringMVC 版本5.3.31后,发现有一个上传文件的接口效率下降了

业务代码如下

    @ResponseBody
    @PostMapping(value = "/uploadFile", produces = MediaType.MULTIPART_FORM_DATA)
    public Response upload1File(@NotNull MultipartFile file, HttpServletRequest request) {
        try (InputStream inputStream = file.getInputStream();) {
            // 具体业务
        }
    }

分析了火焰图,发现使用了MVC框架后,主要在这部分消耗比较多时间

[40]48.31% 9,101 self: 0.02% 3 orglapache/tomcat/util/http/fileupload/MultipartStreamSItemInputStream.makeAvailable
.. [41]30.95% 5,830 self 0.02% 3 org/apache/tomcat/util/http/fileupload/MultipartStreamSItemInputStream.findSeparator
[42]30.93% 5,827 self: 30.93% 5,827 org/apache/tomcat/util/http/fileupload/MultipartStream.findSeparator

serviceComb 处理表单的方法
io.netty.handler.codec.http.multipart.HttpPostMultipartRequestDecoder#findMultipartDelimiter

想问下ServiceComb在对于MultipartFile文件接口有没有做什么优化,还是说可能只是底层一个是tomcat,一个是netty的原因

@liubao68
Copy link
Contributor

liubao68 commented Aug 5, 2024

java chassis的上传下载支持 REST over servletRest over vert.x两种模式。 不同的模式相对于spring boot,都是完全重新实现的,不依赖于Spring MVC的实现。 参考: Java Chassis与Spring Boot 集成介绍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants