# Module Question

**URL:** <https://www.ruby-forum.com/t/module-question/178708>\
**Category:** NGINX\
**Created:** [November 9, 2009, 8:20pm UTC](https://www.ruby-forum.com/t/module-question/178708 "2009-11-09T20:20:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerryw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/848f3c/32.png) [@gerryw](https://www.ruby-forum.com/u/gerryw)\
**Post date:** [November 9, 2009, 8:20pm UTC](https://www.ruby-forum.com/t/module-question/178708/1 "2009-11-09T20:20:28Z")

</div>

Hello All,

I’m considering writing a module that would provide javascript as a  
backend development language. I would like to get some advice on the  
best way to implement this. I was considering using a thread pool/queue  
combination to load and run scripts.

For example:

1. Initialize thread pool/queue on first run and stash pointer in module  
specific storage
2. Receive request
3. Queue request (queuing request wakes up thread to process)
4. Module returns
5. Thread sends response when processing is completed.

Note: threads take care of javasript related activities (ie; load, run,  
etc.).

Does this sound like a workable solution?

Thanks,  
-G

Posted at Nginx Forum:

> **[Module Question](https://forum.nginx.org/read.php?2,21573,21573#msg-21573)**
>
> Hello All, I'm considering writing a module that would provide javascript as a backend development language. I would like to get some advice on the best way to implement this. I was considering using a thread pool/queue combination to load and run...

---

<div class="post-metadata">

**Author:** ![gerryw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/848f3c/32.png) [@gerryw](https://www.ruby-forum.com/u/gerryw)\
**Post date:** [November 9, 2009, 8:52pm UTC](https://www.ruby-forum.com/t/module-question/178708/2 "2009-11-09T20:52:41Z")

</div>

On 11/9/09 2:12 PM, “gerryw” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m considering writing a module that would provide javascript as a backend  
> development language. I would like to get some advice on the best way to  
> implement this.

FastCGI.

---

<div class="post-metadata">

**Author:** ![gerryw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/848f3c/32.png) [@gerryw](https://www.ruby-forum.com/u/gerryw)\
**Post date:** [November 9, 2009, 9:16pm UTC](https://www.ruby-forum.com/t/module-question/178708/3 "2009-11-09T21:16:05Z")

</div>

Hi,

I considered FastCGI, but I’m interested in a self contained solution.  
There would be very little difference in the code between both  
approaches and I didn’t see the point in pushing it out to FastCGI.  
After looking at the FastCGI module, it’s looks like the code I outlined  
will work. The main issue seems to be returning control to nginx as soon  
as possible. Whether the threads are running from nginx or a separate  
FastCGI process should make little difference from a system/performance  
perspective. The self contained solution would be much easier to  
configure/run. Does anyone see any issues with the module based  
approach?

Thanks,  
-G

Posted at Nginx Forum:

> **[Re: Module Question](https://forum.nginx.org/read.php?2,21573,21600#msg-21600)**
>
> Hello All, I'm considering writing a module that would provide javascript as a backend development language. I would like to get some advice on the best way to implement this. I was considering using a thread pool/queue combination to load and run...

---

<div class="post-metadata">

**Author:** ![gerryw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/848f3c/32.png) [@gerryw](https://www.ruby-forum.com/u/gerryw)\
**Post date:** [November 10, 2009, 2:52am UTC](https://www.ruby-forum.com/t/module-question/178708/4 "2009-11-10T02:52:37Z")

</div>

And [Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/v8cgi/)

---

<div class="post-metadata">

**Author:** ![gerryw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/848f3c/32.png) [@gerryw](https://www.ruby-forum.com/u/gerryw)\
**Post date:** [November 10, 2009, 11:24am UTC](https://www.ruby-forum.com/t/module-question/178708/5 "2009-11-10T11:24:45Z")

</div>

Embedding JS in nginx is a kinda great exersize in telepathy 😉

Better check this out:  
[http://nodejs.org/](http://nodejs.org/)

---

<div class="post-metadata">

**Author:** ![gerryw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/848f3c/32.png) [@gerryw](https://www.ruby-forum.com/u/gerryw)\
**Post date:** [November 10, 2009, 2:49am UTC](https://www.ruby-forum.com/t/module-question/178708/6 "2009-11-10T02:49:07Z")

</div>

have a look at this project.

> **[GitHub - rtyler/fastjs: JavaScript FastCGI server based on the v8 engine](https://github.com/rtyler/fastjs)**
>
> JavaScript FastCGI server based on the v8 engine. Contribute to rtyler/fastjs development by creating an account on GitHub.
