Skip to content

Cache query servers in ets table#1778

Merged
janl merged 1 commit intoapache:masterfrom
cloudant:cache_query_servers_in_ets
Nov 29, 2018
Merged

Cache query servers in ets table#1778
janl merged 1 commit intoapache:masterfrom
cloudant:cache_query_servers_in_ets

Conversation

@iilyak
Copy link
Copy Markdown
Contributor

@iilyak iilyak commented Nov 29, 2018

Overview

The configuration of query servers is done via environment variables.
Calling os:getenv every time we need a new query process is expensive.
Instead we extact all configured query servers from the environemt on
couch_proc_manager startup and cache them in ets table.

fixes #1772

Testing recommendations

  1. make eunit
  2. remsh into running dev cluster and check the following
  • ets:tab2list(couch_proc_manager_servers). - returns
    • COFFEESCRIPT
    • QUERY
    • JAVASCRIPT
  • update config to enable native query server config:set("native_query_servers", "enable_erlang_query_server", "true", false).
  • make sure ets:tab2list(couch_proc_manager_servers). includes ERLANG

Related Issues or Pull Requests

Checklist

  • Code is written and works correctly;
  • Changes are covered by tests;
  • Documentation reflects the changes;

The configuration of query servers is done via environment variables.
Calling os:getenv every time we need a new query process is expensive.
Instead we extact all configured query servers from the environemt on
`couch_proc_manager` startup and cache them in ets table.

fixes apache#1772
case get_env_for_spec("COUCHDB_QUERY_SERVER_", UpperLangString) of
[] -> undefined;
[Command] -> Command
case ets:lookup(?SERVERS, string:to_upper(LangStr)) of
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doubtful it’s a performance issue, but we could do to_lower() when populating the ets table so we can avoid to_upper() here on each call. not blocking a merge, just leaving this here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case languages with mixed case will not work.

@janl janl merged commit 8803578 into apache:master Nov 29, 2018
@iilyak iilyak deleted the cache_query_servers_in_ets branch November 29, 2018 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slow operation in couch_proc_manager

2 participants