Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8080447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:25:00+00:00 2026-06-05T16:25:00+00:00

The app I’m working on responds to most requests with JSON objects or collections

  • 0

The app I’m working on responds to most requests with JSON objects or collections thereof. We’re using Jbuilder to construct those responses. The amount of data rendered is fairly large (several thousand objects in various nested structures – once formatted and fully expanded, there are as many as 10,000 lines of JSON for a typical response). This rendering is taking a significant amount of time – about 1/3 of the total request time, according to NewRelic.

I’m looking for some kind of guide, set of tips, or other resource that will help me make sure I’m getting the best possible performance out of JBuilder. I’m also curious if there are performance comparisons available for Jbuilder vs. RABL or other similar tools.

Edit: I’ve found a GitHub Issue that complains about Jbuilder performance, but the only actual suggestion anyone’s made is ‘don’t use Jbuilder’. Well, actually, they used slightly stronger language, but there’s still no word on why Jbuilder is so slow, what, if anything, can be done to get around it, or how other tools for the same task compare.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:25:01+00:00Added an answer on June 5, 2026 at 4:25 pm

    jbuilder builds up a big hash containing your data and then uses ActiveSupport::JSON to turn it into json. There are faster json emitters as the following micro benchmark shows (make sure you have the multijson and yajl-ruby gems installed)

    require 'benchmark'
    require 'active_support'
    require 'multi_json'
    sample = {menu: {
        header: "SVG Viewer",
        items: [
            {id: "Open"},
            {id: "OpenNew", label: "Open New"},
            nil,
            {id: "ZoomIn", label: "Zoom In"},
            {id: "ZoomOut", label: "Zoom Out"},
            {id: "OriginalView", label: "Original View"},
            nil,
            {id: "Quality"},
            {id: "Pause"},
            {id: "Mute"},
            nil,
            {id: "Find", label: "Find..."},
            {id: "FindAgain", label: "Find Again"},
            {id: "Copy"},
            {id: "CopyAgain", label: "Copy Again"},
            {id: "CopySVG", label: "Copy SVG"},
            {id: "ViewSVG", label: "View SVG"},
            {id: "ViewSource", label: "View Source"},
            {id: "SaveAs", label: "Save As"},
            nil,
            {id: "Help"},
            {id: "About", label: "About Adobe CVG Viewer..."}
        ]
    }}
    
    
    MultiJson.engine = :yajl
    Benchmark.bmbm(5) do |x|
      x.report 'activesupport' do
        1000.times {ActiveSupport::JSON.encode(sample)}
      end
      x.report 'yajl' do
        1000.times {MultiJson.encode(sample)}
      end
    end
    

    On my machine this produces

                        user     system      total        real
    activesupport   1.050000   0.010000   1.060000 (  1.068426)
    yajl            0.020000   0.000000   0.020000 (  0.021169)
    

    ie to encode the sample object 1000 times active support took a hair over 1 second, MultiJson (using the yajl engine) took 21ms.

    JBuilder is hardcoded to use ActiveSupport::JSON, but MultiJSON (a gem that lets you switch between json libraries) is a trivial drop in and is already a dependency of ActiveSupport – see my fork of jbuilder. I’ve opened a pull request, but until then you could try using this fork (or create your own – it’s a one line change)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app keeps track of the state of about 1000 objects. Those objects are
The app I'm working on is relatively simple but it is throwing memory warnings.
The app Im working on uses gps and sometimes in the onResume when the
My app is crashing using iOS5 and iOS4.3 iPhone simulators in Xcode 4.2, the
My app is slowed down by N+1 queries. I'm using the will_paginate gem with
We're building an app, our first using Rails 3, and we're having to build
my app was working perfectly fine, until I cleaned the targets and deleted the
Our app (already deployed) is using an Access/Jet database. The upcoming version of our
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.