Skip to content

Spring is slow with LaunchDarkly enabled #105

@jeromedalbert

Description

@jeromedalbert

Config

We are using the 5.0.1 version of this gem.

Here is our LaunchDarkly Spring config, as per the docs:

# config/spring.rb

Spring.after_fork do
  config = LaunchDarkly::Config.new(logger: Logger.new('/dev/null'))
  Rails.configuration.ld_client = LaunchDarkly::LDClient.new(ENV['LD_KEY'], config)
end

Problem

When spring is already loaded, Spring takes 1.5 seconds to boot:

$ time (rails c)
Loading development environment (Rails 5.1.6)
[1] pry(main)>
( rails c; )  0.24s user 0.10s system 22% cpu 1.521 total

1.5 seconds is too long, booting rails should feel instant since spring is already loaded.

Notes

  • Removing the LD config from Spring makes Rails boot back to 0.5 seconds, which is ideal. But then the LD client will fail to receive updates.
  • Is there any way to make the LD client work with Spring while not impacting Spring boot time? Because at the moment this makes all our Spring commands (console, rspec, rake tasks...) slower by a good 1 second.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions