# How does FastCGI work under the covers?

**URL:** <https://www.ruby-forum.com/t/how-does-fastcgi-work-under-the-covers/235568>\
**Category:** NGINX\
**Created:** [June 30, 2013, 11:11pm UTC](https://www.ruby-forum.com/t/how-does-fastcgi-work-under-the-covers/235568 "2013-06-30T23:11:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [June 30, 2013, 11:11pm UTC](https://www.ruby-forum.com/t/how-does-fastcgi-work-under-the-covers/235568/1 "2013-06-30T23:11:57Z")

</div>

Hello Everybody,

I have a simple question about the Nginx FastCGI implementation. Let’s  
say  
that 1,000 web browsers are requesting pages from our server, and we’re  
using FastCGI within Nginx.

While the FastCGI specification permits sending little pieces of each  
request (“multiplexing” them), my understanding is that most (all?)  
implementations don’t do this. Therefore,

(1) does Nginx FastCGI provide exactly one complete HTTP request at a  
time?

(2) does Nginx FastCGI want us to respond to that particular HTTP  
request  
before it gives us the next one?

The reason that I ask is this: If my FastCGI server is high-latency,  
I’m  
wondering if it can get lots of requests to work on, or if it will have  
to  
finish one and only then get the next one, and only Nginx knows the  
answer  
to this question. 🙂

Many thanks for your kind help, and I hope that I didn’t miss the answer  
to  
this question in my search of the archives.

kgk

Posted at Nginx Forum:

> **[How does FastCGI work under the covers?](https://forum.nginx.org/read.php?2,240429,240429#msg-240429)**
>
> Hello Everybody, I have a simple question about the Nginx FastCGI implementation. Let's say that 1,000 web browsers are requesting pages from our server, and we're using FastCGI within Nginx. While the FastCGI specification permits sending little...

---

<div class="post-metadata">

**Author:** ![kgk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/edb3f5/32.png) [@kgk](https://www.ruby-forum.com/u/kgk)\
**Post date:** [July 1, 2013, 12:36am UTC](https://www.ruby-forum.com/t/how-does-fastcgi-work-under-the-covers/235568/2 "2013-07-01T00:36:04Z")

</div>

Hello!

On Sun, Jun 30, 2013 at 05:10:23PM -0400, kgk wrote:

> (1) does Nginx FastCGI provide exactly one complete HTTP request at a  
> time?
> 
> (2) does Nginx FastCGI want us to respond to that particular HTTP request  
> before it gives us the next one?
> 
> The reason that I ask is this: If my FastCGI server is high-latency, I’m  
> wondering if it can get lots of requests to work on, or if it will have to  
> finish one and only then get the next one, and only Nginx knows the answer  
> to this question. 🙂

FastCGI multiplexing isn’t used by nginx. That is, within a  
single connection to a fastcgi application only one request is  
sent, and then nginx will wait for a response. More connections  
will be opened if there are multiple simulteneous requests.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**

---

<div class="post-metadata">

**Author:** ![kgk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/edb3f5/32.png) [@kgk](https://www.ruby-forum.com/u/kgk)\
**Post date:** [July 1, 2013, 6:21pm UTC](https://www.ruby-forum.com/t/how-does-fastcgi-work-under-the-covers/235568/3 "2013-07-01T18:21:08Z")

</div>

Hello Maxim,

Thank you so much for answering my previous questions! Now I have a few  
more:

1. Will Nginx provide a FastCGI request only when it is 100% complete,  
i.e., the browser has provided every necessary byte?

2. Will Nginx always accept 100% of a FastCGI response and hold it  
inside  
internal buffers (or on disk), and not wait for the client (= web  
browser)?

kgk

Maxim D. Wrote:

* * *

> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,240429,240453#msg-240453](http://forum.nginx.org/read.php?2,240429,240453#msg-240453)

---

<div class="post-metadata">

**Author:** ![kgk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/edb3f5/32.png) [@kgk](https://www.ruby-forum.com/u/kgk)\
**Post date:** [July 1, 2013, 7:09pm UTC](https://www.ruby-forum.com/t/how-does-fastcgi-work-under-the-covers/235568/4 "2013-07-01T19:09:02Z")

</div>

Hello!

On Mon, Jul 01, 2013 at 11:57:21AM -0400, kgk wrote:

> Hello Maxim,
> 
> Thank you so much for answering my previous questions! Now I have a few  
> more:
> 
> 1. Will Nginx provide a FastCGI request only when it is 100% complete,  
> i.e., the browser has provided every necessary byte?

Yes.

> 1. Will Nginx always accept 100% of a FastCGI response and hold it inside  
> internal buffers (or on disk), and not wait for the client (= web browser)?

Depends on configuration, see  
[Module ngx\_http\_fastcgi\_module](http://nginx.org/r/fastcgi_max_temp_file_size).

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
