繁体   English   中英

OCELOT 中的旁路端点 API 网关端点

[英]Bypass endpoint in OCELOT API gateway endpoint

我有一个端点正在向服务器上传多达 200MB 的视频。 每当我尝试同时上传超过 3 个视频时,网关会抛出 404 错误并显示以下错误消息:

warn: Ocelot.Responder.Middleware.ResponderMiddleware[0]
  requestId: 0HMFL2SCVRST5:00000001, previousRequestId: no previous request id, message: Error Code: UnmappableRequestError Message: Error when parsing incoming request, exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
     at System.IO.MemoryStream.set_Capacity(Int32 value)
     at System.IO.MemoryStream.EnsureCapacity(Int32 value)
     at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
     at System.IO.MemoryStream.WriteAsync(ReadOnlyMemory`1 buffer, CancellationToken cancellationToken)
  --- End of stack trace from previous location where exception was thrown ---
     at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.CopyToAsyncInternal(Stream destination, CancellationToken cancellationToken)
     at Ocelot.Request.Mapper.RequestMapper.ToByteArray(Stream stream)
     at Ocelot.Request.Mapper.RequestMapper.MapContent(HttpRequest request)
     at Ocelot.Request.Mapper.RequestMapper.Map(HttpRequest request, DownstreamRoute downstreamRoute) errors found in ResponderMiddleware. Setting error response for request path:/v1/Video/UploadVideo, request method: POST

如果我在服务器上增加 memory 用户增加时可能会出现此问题。 那么,是否有 UploadVideo 端点直接访问 webhost 而不是通过网关访问 go?

我正在使用 Ocelot API 网关。

请先阅读有关OutOfMemoryException Class 的官方文档。

从字面上看,问题是 memory 不够用。 所以如果增加memory可以缓解,但是当用户量大的时候还是会出现这个问题。

如果我们不使用第三方服务,我们可以限制视频的大小,上传的数量,或者限制同时上传的任务只有几个。 但这不是最好的解决方案。

一般情况下,我们还是会考虑使用媒体服务。 Azure 媒体服务 让web服务器,只负责web的服务,可以更高效的做网站。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM