Content
You are here:
[SOLVED] Every page take 4 seconds to load
Added by Jasper Visser about 11 years ago
Hi,
I have a fresh local installation of openproject on a fairly high-end laptop (16GB/8-core/SSD). For some reason, every page under http://localhost:3000 takes ~4 seconds to load.
There’s surprisingly little variance. It’s almost 4 seconds for every page, regardless of the page content. If I look at the output of script/server:
- First it waits ~3.5 seconds (no logging)
- Then follow the queries (each takes 0-2 ms)
- Finally it logs something like Completed in 4340ms (View: 3943, DB: 24) | 200 OK [http://localhost/projects/axle/activity]
I tried to google for this problem. My best guess is that it might have something to do the number of gems installed. It does seem likely, because the long wait occurs before the script starts doing any work. I’m not really familiar with Ruby.
Can anyone point me in the right direction of how I could approach solving this problem?
Yours,
Jasper
Replies (8)
Hi Jasper,
the 4 second delay is just normal, because rails reloads most of the OpenProject codebase (and compiles assets) at every request (I experience a similar delay).
To make things fast, run the app in production mode:
bundle exec rake generate_secret_token # only required for the very first time
bundle exec rake assets:precompile # required every time the assets change, takes some time
config/environments/production.rb
and change theconfig.serve_static_assets
-setting totrue
(usually a web server serves assets. You probably have no web server configured at your laptop, so we have to tell rails to do the job)RAILS_ENV=production bundle exec rails server
The very first request takes a second. Every other request should be fast. Remember to restart the server, if you change any code in production mode.
Yours,
Philipp
Hi Philipp,
Good to hear it’s an expected result. It might be worthwhile to add these steps as an encore to the wiki/Download_and_Installation.
Or maybe this is standard Ruby stuff. Like I said, Ruby is not my language, so I have no idea where it ends and openproject specific code starts. :)
bundle exec rake generate_secret_token
This command also starts the server, which seems odd to me. It also doesn’t log anything related to secret tokens:
Is that expected?
bundle exec rake assets:precompile
This just echoes:
For the record, I am on the master branch of the openproject git. Installed as per the procedure listed under 1.3. Manual installation. The changelog calls it v2.4.0.
config/environments/production.rb
There is no such setting yet to change, but I added it. I do actually have Apache running, and occassionally node or Jetty. :)
RAILS_ENV=production bundle exec rails server
I assume that this should be two separate lines:
Got it.
However, after the above, if I start script/server, it says:
with a nice stack trace that doesn’t seem interesting enough to post here. Maybe related to one of the problems mentioned above?
Yours,
Jasper
Oh I should have asked first which OpenProject version you are running (the rails 2 version behaves different than our current rails 3 version).
Can you, please, run
and give me the output?
I’m on github/master. These are the last two commits I see:
069b1c9 Merge pull request #320 from marutosi/finn-eof
eafc68f add newline at end of public/422.html
Good to know. I just gave you the instructions for OpenProject 3.0 (which is in beta at the moment, you’ll find it at the
feature/rails3
branch).Give me a minute to adapt my steps to your branch.
No hurry at all.
Alternatively, I could switch to 3.0. For the moment, I only plan to use it for my own (small) team, and a certain level of instability wouldn’t bother us.
Ok, lets try again :)
With all command
sudo
shouln’d be needed. Execute the commands as is (withoutscript/server
or anything in front of it)bundle exec rake generate_session_store
if you not have done that beforeRAILS_ENV=production bundle exec script/server
to start the serverThanks. Sorry it took me a month to get back to this, but I want to make sure that the thread is closed with the words “SOLVED”. :)