Hey guys, long time no see..

I was trying to solve my problem these last three months but without
success..

Today, I've decided to try again some things, and for some reason I found
the solution..

At bootstrap.php, I had declared three lines to get the hostname of the user
for each request, and I've figured out that my network spend long time to
resolve the reverse DNS.

The solution for me was just remove the following three lines I added
before:

$hostName = gethostbyaddr($_SERVER["SERVER_ADDR"]);
$hostName = gethostbyname($hostName);
define('SERVER_HOSTNAME', $hostName, true);


Now each request takes around 250ms, that is really faster than before.. :-)

Thanks everyone for the help..


Atenciosamente,

*Thiago Elias Rezende Silva*
*Analista/Programador php
www.systemdevelopers.com.br
**+55 13 8113-4710*



2010/8/16 Thiago Elias <[email protected]>

> Thanks jmn2k1 and djogo for the new answers here..
>
> I'm really using IP Address instead hostname for database connection..
>
> Guys, I Haven't tried the proposed solutions yet, but this week I'll try
> them all.. (these days I'm running against time to put some things in order
> here.. haha)..
>
> Thanks for the help.
>
> Thiago Elias.
>
>
> 2010/8/13 djogo <[email protected]>
>
>  jmn2k1, sometimes even the network routing messes with database access
>> speed... We had a problem in which every request passed by the
>> firewall, even to our own servers! The firewall couldn't handle the
>> traffic, therefore everything (internet and intranet access) was so
>> slow.
>>
>>
>> On Aug 13, 11:17 am, jmn2k1 <[email protected]> wrote:
>> > Not necessarily your case but once I had a similar problem, it turns
>> > out I was using a hostname for the database server that need to do a
>> > DNS checkout and hence slow the app down. If you're using the ip then
>> > this is not the case.
>> >
>> > On Aug 12, 10:14 am, Thiago Elias <[email protected]> wrote:
>> >
>> > > Hey Guys..
>> >
>> > > Thanks everyone for the answers.. I'll try them all here today, and
>> I'll
>> > > post the results soon as possible..
>> >
>> > > 2010/8/12 djogo <[email protected]>
>> >
>> > > > Hi Thiago,
>> >
>> > > > I would try to replicate the entire system (lampp + your app +
>> > > > database) in other server and check whether the "slowness" is due to
>> > > > the server or not. You may also replicate a legacy PHP app, as you
>> > > > call it, to check if it works well too. This replicated server will
>> > > > allow you to test other experiments without jeopardizing your real
>> > > > production data.
>> >
>> > > > If the performance in the replicated server is equivalent to your
>> > > > original one, check if its something in the cakephp lib. Create a
>> > > > controller that doesn't use any models at all. If it's also slow,
>> than
>> > > > the problem is something about your cake, or its configuration. If
>> > > > it's not, then it's probably your database.
>> >
>> > > > Then you can start thinking about database optimization. Is all
>> > > > queries slow? Try a simple "SELECT 1 FROM DUAL" in the legacy PHP
>> and
>> > > > in cakePHP. how many milisseconds each one takes (test both on the
>> > > > browser)? Is AppController->beforeFilter doing something that may be
>> > > > slowing down your queries?
>> >
>> > > > Turn debug to 2 and for each query that it reports, check how much
>> > > > time is it taking (it's right beside the query name). Try to run the
>> > > > same query on the database directly and check if the timing is
>> > > > compatible.
>> >
>> > > > When my apps turn slow, I always think of the DB. Sometimes, it's
>> just
>> > > > a matter of creating the right indexes - for instance, if you run
>> > > > "SELECT marafo_id, count(*) from naosei group by marafo_id", it'll
>> be
>> > > > really slow when you have lots (>100K) of rows and the grouped
>> column
>> > > > is not indexed. A simple "CREATE INDEX index_naosei_marafo_id ON
>> > > > naosei (marafo_id);" would solve this problem.
>> >
>> > > > Well, keep us all informed about these results. I'm very interested
>> > > > because every once in a while I (and may I add, everybody =]) run
>> into
>> > > > this kind of problem too.
>> >
>> > > > dfcp
>> >
>> > > > On 11 ago, 22:29, Thiago Elias <[email protected]> wrote:
>> > > > > Hi All,
>> >
>> > > > > Since two or three months ago (more or less), I'm experiencing
>> some
>> > > > problems
>> > > > > involving CakePHP.
>> >
>> > > > > In the past, our application was using a local database
>> connection, and
>> > > > > performance was really nice and acceptable. Some months ago, we
>> had to
>> > > > > migrate the application to another server, separating the Data and
>> the
>> > > > Apps.
>> >
>> > > > > After this change, I've lost performance in my cake App. Each
>> request
>> > > > takes
>> > > > > around 10 ~ 15 seconds, and before, was 2 ~ 3,5 secs.
>> > > > > The interesting thing is: The other legacy PHP Apps are 100% fast,
>> and
>> > > > even
>> > > > > other cakeAPPs are fast too, but the difference is: My main cake
>> app (the
>> > > > > one that lost performance) have 80 innoDB Tables and 20 views.
>> (used to
>> > > > link
>> > > > > to another databases).
>> >
>> > > > > I'm using CakePHP 1.2.7, PHP 5.2. And in the Database Server,
>> MySQL
>> > > > Server
>> > > > > 5.1.
>> > > > > Our network infrastructure is really fast, and ping response
>> between
>> > > > servers
>> > > > > is really nice.
>> >
>> > > > > Does anyone knows why I'm losing performance just in this App when
>> > > > connected
>> > > > > to a remote server ?! I'm using CakePHP Debug, and ~85% of the
>> time spent
>> > > > in
>> > > > > the request is lost in the CORE, and not in the app. (The core is
>> the
>> > > > same
>> > > > > of the other cakeApps..)
>> >
>> > > > > Please help-me (and sorry for my bad english).
>> >
>> > > > > Thiago Elias
>> >
>> > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
>> others
>> > > > with their CakePHP related questions.
>> >
>> > > > You received this message because you are subscribed to the Google
>> Groups
>> > > > "CakePHP" group.
>> > > > To post to this group, send email to [email protected]
>> > > > To unsubscribe from this group, send email to
>> > > > [email protected]<cake-php%[email protected]>
>> <cake-php%[email protected]<cake-php%[email protected]>>For
>> more options, visit this group at
>> > > >http://groups.google.com/group/cake-php?hl=en
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help
>> others with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]<cake-php%[email protected]>For
>>  more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to