Thanks again for your time and consideration.
I was already trying to implement body "downstream" reading,
and just location.capture only to storage (as step 1)
I'll let you know soon when I'm going further with that.
Pierre
On 03/mai - 21:35, agentzh wrote:
> On Thu, May 3, 2012 at 5:43 AM, Pierre <ser...@baqs.net> wrote:
> > I take the opportunity to contact you directly to get more details about
> > cosocket functions.
> >
> > First of all, let me tell you a bit more about what I try to do.
> > My goal is to spread files from a server to another.
> >
> > server 1 � � � �-> storage1
> > � � � � � � � �-> storage2
> > � � � � � � � �-> storage3
> > � � � � � � � �-> storage4
> >
> >
> > When file is uploaded on server1, it's devided into small chunks (for memory purpose),
> > reading body tempfile by x MB.
> >
> > my problem is I make to many subrequests.
> > Here is my configuration file:
> >
> >
> > upstream storage1
> > {
> > ..
> > }
> > upstream storage2..3..4
> >
> >
> > location /
> > {
> > �if ($request_method = PUT )
> > �{
> > � � content_by_lua_file /scripts/lua/put.lua;
> > �}
> > }
> >
> > put.lua does location_capture to /store
> >
> > location = /store {
> > � �# MANDATORY
> > � �internal;
> > � �# MANDATORY
> >
> > � echo_read_request_body;
> > � set $lbList 'lb1,lb2,lb3,lb4' ;
> > � echo_foreach_split ',' $lbList;
> > � � � echo_subrequest_async PUT /once -q 'lbgroup=$echo_it&chunk=$arg_chunk' �-b $echo_request_body;
> > � echo_end;
> > }
> > location /once {
> > � �# MANDATORY
> > � �internal;
> > � �# MANDATORY
> > � �proxy_set_header �X-Real-IP �$remote_addr;
> >
> > � �proxy_pass � � � �http://$arg_lbgroup/store?chunk=$arg_chunk;
> > }
> >
> >
> > So, for each chunk, I make 4 subrequests.
> >
> >
> > Thus, I'm wondering what could be my interest in using cosocket :
> >
> > - How could I give the data from server1 to each "storage" server ?
> > I see the point and benefit of using cosockets to connect to local server (like memcache,redis,mysql),
> > but how could I implement it to dialog with foreign servers ?
> >
>
> If you're using the cosocket API, then you cannot use the ngx_proxy
> module. You need something like an HTTP driver that is based on
> cosocket, as in
>
> https://github.com/agentzh/lua-resty-http
>
> > I think I missed something important in the use of cosockets.
> >
>
> The cosocket API provides TCP and Unix Domain Socket client socket
> API. If you need higher-level TCP protocols like HTTP, then you need a
> high-level Lua driver to talk to the remote HTTP servers.
>
> And ngx_lua supports downstream cosocket API to read the request body
> in the streaming fashion:
>
> http://wiki.nginx.org/HttpLuaModule#ngx.req.socket
>
> And the lua-resty-upload library is based on this to support streaming
> big file uploading:
>
> https://github.com/agentzh/lua-resty-upload
>
> > Thanks in advance for your time, and congratulations for the enormous work you've been doing in all your work aroud nginx.
> >
>
> Thank you :)
>
> Best regards,
> -agentzh
>
> P.S. I've cc'd the openresty mailing list so that the whole team can
> see our discussion here. There's no sensitive information in your mail
> anyway ;) https://groups.google.com/group/openresty