简体   繁体   English

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

[英]Bypass endpoint in OCELOT API gateway endpoint

I have one endpoint which is uploading upto 200MB videos to the server.我有一个端点正在向服务器上传多达 200MB 的视频。 Whenever I try to upload more than 3 videos simultaneously, gateway is thowing 404 error with below error message:每当我尝试同时上传超过 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

If I increase memory on the server this issue may come up when users increased.如果我在服务器上增加 memory 用户增加时可能会出现此问题。 So is there anyway UploadVideo endpoint to be directly hitting the webhost and not go through the gateway?那么,是否有 UploadVideo 端点直接访问 webhost 而不是通过网关访问 go?

I am using the Ocelot API gateway.我正在使用 Ocelot API 网关。

Please read this official doc about OutOfMemoryException Class first.请先阅读有关OutOfMemoryException Class 的官方文档。

The problem is literally, that the memory is not enough to use.从字面上看,问题是 memory 不够用。 So if you increase the memory, it can be alleviated, but when the number of users is large, this problem will still occur.所以如果增加memory可以缓解,但是当用户量大的时候还是会出现这个问题。

If we don't use third-party services, we can limit the size of the video, the number of uploads, or set a limit to only a few upload tasks at the same time.如果我们不使用第三方服务,我们可以限制视频的大小,上传的数量,或者限制同时上传的任务只有几个。 But this is not the best solution.但这不是最好的解决方案。

Under normal circumstances, we still consider using media services.一般情况下,我们还是会考虑使用媒体服务。 Such as Azure Media Service .Azure 媒体服务 Let the web server, only responsible for web services, can conduct sites more efficiently.让web服务器,只负责web的服务,可以更高效的做网站。

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

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