# Nginx lua capture\_multi fire and forget

**URL:** <https://www.ruby-forum.com/t/nginx-lua-capture-multi-fire-and-forget/237079>\
**Category:** NGINX\
**Created:** [October 23, 2013, 11:47am UTC](https://www.ruby-forum.com/t/nginx-lua-capture-multi-fire-and-forget/237079 "2013-10-23T11:47:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [October 23, 2013, 11:47am UTC](https://www.ruby-forum.com/t/nginx-lua-capture-multi-fire-and-forget/237079/1 "2013-10-23T11:47:19Z")

</div>

Hi all,

We’re currently using the lua capture\_multi to send production request  
to  
test systems.  
And sometimes we also kind of ‘fork’ these request to multiple test  
systems.

But if one of the test systems is slow to respond the lua code waits  
till it  
gets all responses.  
And this is something we actually don’t like to have.

Is there a way to have the lua module launch the requests without  
waiting  
for the response?  
It should fire the requests and continue directly afterwards and forget  
about the response handling.  
I could try and modify the lua module, but I’m not really familiar with  
C/C++ coding.

Here’s a config sample:  
[http://pastebin.com/U5qgXCFh](http://pastebin.com/U5qgXCFh)

Thanks in advance,  
Pieter

Posted at Nginx Forum:

> **[Nginx lua capture\_multi fire and forget](https://forum.nginx.org/read.php?2,244032,244032#msg-244032)**
>
> Hi all, We're currently using the lua capture\_multi to send production request to test systems. And sometimes we also kind of 'fork' these request to multiple test systems. But if one of the test systems is slow to respond the lua code waits till it...

---

<div class="post-metadata">

**Author:** ![PieterVI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c67d28/32.png) [@PieterVI](https://www.ruby-forum.com/u/PieterVI)\
**Post date:** [October 26, 2013, 8:09am UTC](https://www.ruby-forum.com/t/nginx-lua-capture-multi-fire-and-forget/237079/2 "2013-10-26T08:09:25Z")

</div>

Hello!

On Wed, Oct 23, 2013 at 2:46 AM, PieterVI wrote:

> Is there a way to have the lua module launch the requests without waiting  
> for the response?  
> It should fire the requests and continue directly afterwards and forget  
> about the response handling.  
> I could try and modify the lua module, but I’m not really familiar with  
> C/C++ coding.

Completely forget the response handling is not a really good thing to  
do here. You can, however, make the upstream requests and response  
handling run in the “background” without adding any latency to your  
downstream requests. Basically, you can just use ngx\_lua’s timer API  
and lua-resty-http-simple library for this:

```
https://github.com/chaoslawful/lua-nginx-module#ngxtimerat
https://github.com/bakins/lua-resty-http-simple

```

The only limitation (right now) is that lua-resty-http-simple does not  
support https yet. Hopefully you don’t use it.

BTW, it looks like you’re trying to do something that tcpcopy may help  
you:

```
https://github.com/wangbin579/tcpcopy

```

BTW 2: you may want to join the openresty-en mailing list for such  
questions so that you may get faster responses:

```
https://groups.google.com/group/openresty-en

```

This is also recommended in ngx\_lua’s official documentation:

```
https://github.com/chaoslawful/lua-nginx-module#community

```

Best regards,  
-agentzh
