# Ajax really slow in production, very weird

**URL:** <https://www.ruby-forum.com/t/ajax-really-slow-in-production-very-weird/177850>\
**Category:** Rails\
**Created:** [October 25, 2009, 12:22pm UTC](https://www.ruby-forum.com/t/ajax-really-slow-in-production-very-weird/177850 "2009-10-25T12:22:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![phoenix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/0ea827/32.png) [@phoenix](https://www.ruby-forum.com/u/phoenix)\
**Post date:** [October 25, 2009, 12:22pm UTC](https://www.ruby-forum.com/t/ajax-really-slow-in-production-very-weird/177850/1 "2009-10-25T12:22:33Z")

</div>

It works fine when I start a single instance of mongrel or thin. But  
when I use thin cluster or passenger, some ajax is really slow, takes  
about 2 minutes to complete. Any sugestion? By the way, I tried  
passenger for nginx and nginx + thin cluster.

---

<div class="post-metadata">

**Author:** ![phoenix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/0ea827/32.png) [@phoenix](https://www.ruby-forum.com/u/phoenix)\
**Post date:** [October 25, 2009, 6:22pm UTC](https://www.ruby-forum.com/t/ajax-really-slow-in-production-very-weird/177850/2 "2009-10-25T18:22:30Z")

</div>

What does your production log say? How many ms does it take to render  
your request?

---

<div class="post-metadata">

**Author:** ![phoenix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/0ea827/32.png) [@phoenix](https://www.ruby-forum.com/u/phoenix)\
**Post date:** [October 26, 2009, 2:30am UTC](https://www.ruby-forum.com/t/ajax-really-slow-in-production-very-weird/177850/3 "2009-10-26T02:30:02Z")

</div>

It looks that the request has problems reach a thin instance, as soon  
as it reaches the thin instance, the request completes quickly. The  
production log says it took about 150000ms to complete the request.  
But not all the request has the problem, some of them complete within  
half a second which is normal. I’m guessing that nginx has problems  
dispatching the request to a thin or passenger instance. Has any body  
encountered this problem before?

On Oct 26, 1:22 am, Wouter de Bie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![phoenix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/0ea827/32.png) [@phoenix](https://www.ruby-forum.com/u/phoenix)\
**Post date:** [October 26, 2009, 3:32am UTC](https://www.ruby-forum.com/t/ajax-really-slow-in-production-very-weird/177850/4 "2009-10-26T03:32:42Z")

</div>

first, I’m sure my connection to the internet is ok.  
And the problem exist after i restart nginx and thin, and it is  
repeatable.  
I did tested on my local machine with the same configuration, it works  
fine.  
I used ubuntu 8.10 on my local machine, but the server runs on freebsd  
7.2, so maybe there’s some difference.

---

<div class="post-metadata">

**Author:** ![phoenix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/0ea827/32.png) [@phoenix](https://www.ruby-forum.com/u/phoenix)\
**Post date:** [October 26, 2009, 3:14am UTC](https://www.ruby-forum.com/t/ajax-really-slow-in-production-very-weird/177850/5 "2009-10-26T03:14:32Z")

</div>

On Sun, Oct 25, 2009 at 6:28 PM, phoenix [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It looks that the request has problems reach a thin instance, as soon  
> as it reaches the thin instance, the request completes quickly. The  
> production log says it took about 150000ms to complete the request.  
> But not all the request has the problem, some of them complete within  
> half a second which is normal. I’m guessing that nginx has problems  
> dispatching the request to a thin or passenger instance. Has any body  
> encountered this problem before?

Is this a local or remote deployment? In any case, I would do the  
following:

1. check your connection to the internet
2. check with your New Relic or other performance monitoring to track  
the  
issue
3. re-check the overall configuration of the system
4. reboot nginx and thin servers and see if the problem still persists
5. check with the hosting company
6. do testing in production mode on you local system using the same  
remote  
configuration to see if the issue exists

Good luck,

-Conrad

---

<div class="post-metadata">

**Author:** ![phoenix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/0ea827/32.png) [@phoenix](https://www.ruby-forum.com/u/phoenix)\
**Post date:** [October 26, 2009, 4:51am UTC](https://www.ruby-forum.com/t/ajax-really-slow-in-production-very-weird/177850/6 "2009-10-26T04:51:42Z")

</div>

I got the problem solved!

It turned out to be a directory access problem. I used texlive for  
math formular editing, and the access mod for directory that contains  
these executables is 777. After I changed it to 755, the problem  
disapeared. I overlooked a warning in my log, which says: ‘world  
writable directory /xxx/xxx’. And I didn’t expect this would cause  
such weird behavior, I don’t see much connection here…

I wasted a lot of time on this and it really taught me a lesson!

Thanks for all your kind help. You are a very nice man!

---

<div class="post-metadata">

**Author:** ![phoenix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/0ea827/32.png) [@phoenix](https://www.ruby-forum.com/u/phoenix)\
**Post date:** [October 26, 2009, 4:49am UTC](https://www.ruby-forum.com/t/ajax-really-slow-in-production-very-weird/177850/7 "2009-10-26T04:49:56Z")

</div>

On Sun, Oct 25, 2009 at 7:30 PM, phoenix [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> first, I’m sure my connection to the internet is ok.

You’re sure but did you check it.

> And the problem exist after i restart nginx and thin, and it is  
> repeatable.

I did tested on my local machine with the same configuration, it works

> fine.

I used ubuntu 8.10 on my local machine, but the server runs on freebsd

> 7.2, so maybe there’s some difference.

It’s not really the same configuration if you’re using binaries built  
for  
Linux  
locally and FreeBSD binaries remotely. In theory, they would be the  
same  
but in practice they may not be. Did you check with your hosting  
company?  
What do the logs say for both nginx and thin? What’s the performance  
like  
without Javascript enabled?

-Conrad
