How to improve the performance of a single-page application?

Introduction
I have a (mostly) single-page application built with BackboneJS and the Rails backend.

Since most of the interaction takes place on one webapp page, when the user first visits the page, I basically need to pull a ton of information from the database in one large, deeply connected query.

This causes me some extreme loads on this page.

load times

NewRelic seems to tell me that most of my problems are related to 457 individual quick method calls.

fast methid calls

Now I have done all the downloaded download that I can do (I checked with the Bullet gem ) and I still have a problem.

These method calls most likely occur in my Rabl serializer , which I use to serialize the JSON bundle to insert into the page to initialize the trunk. You do not need to understand all this, but suffice it to say that it can add up to 457 method calls.

object @search
attributes :id, :name, :subscription_limit

# NOTE: Include a list of the members of this search.
child :searchers => :searchers do
  attributes :id, :name, :gravatar_icon
end

# Each search has many concepts (there could be over 100 of them).
child :concepts do |search|
  attributes :id, :title, :search_id, :created_at

  # The person who suggested each concept.
  child :suggester => :suggester do
    attributes :id, :name, :gravatar_icon
  end

  # Each concept has many suggestions (approx. 4 each).
  node :suggestions do |concept|
    # Here I'm scoping suggestions to only ones which meet certain conditions.
    partial "suggestions/show", object: concept.active_suggestions
  end

  # Add a boolean flag to tell if the concept is a favourite or not.
  node :favourite_id do |concept|
    # Another method call which occurs for each concept.
    concept.favourite_id_for(current_user)
  end
end

# Each search has subscriptions to certain services (approx. 4). 
child :service_subscriptions do
  # This contains a few attributes and 2 fairly innocuous method calls.
  extends "service_subscriptions/show"
end

So it seems that I need to do something, but I'm not sure which approach to take. Here is a list of potential ideas that I have:

Performance Improvement Ideas

Drop the interface.

Perhaps I can come up with ways to provide information to a user who does not require actual data. I don’t understand why I need this, but other single-page applications, such as Trello , have incredibly complex interfaces.


, , . .


. , , . , , , .


, JSON , , , , , , , .


, . , (, ?) .


, , , . , .


- - , ?

+5
2

, , , . , , , , , . , 100 "", , ?

, , - , , , , , , .

+1

JS- , , RequireJS. , XHR, .

, , .

, . , polling , .

+1

All Articles