Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add frappe cmd and doctype to request headers for analytics and load balancing #7228

Merged
merged 2 commits into from May 20, 2019

Conversation

sachinhub
Copy link
Contributor

Frappe CMD and Doctype details are deep inside the POSTed HTTP body. If brought at the HTTP header level would help in more powerful load balancing at the webserver level and also in logging.

e.g. following snippet in nginx config allows routing based on http header to different backend ERPNext servers -

map $http_x_frappe_cmd $backend_server {
  "frappe.desk.reportview.export_query" replica-first;
  "frappe.desk.reportview.get_sidebar_stats" replica-first;
  "frappe.desk.reportview.get" replica-first;
  "frappe.desk.query_report.run" replica-first;
  "frappe.model.db_query.get_list" replica-first;
  "frappe.client.get_count" replica-first;
  "frappe.desk.notifications.get_open_count" replica-first;
  "frappe.utils.print_format.download_multi_pdf" quarantine;
}

upstream primary-first {
  server wra01.ntex.com;
}

upstream replica-first {
  server wra01.ntex.com;
  server wra02.ntex.com;
  server wra03.ntex.com;
  server backup-wra.ntex.com backup;
}

upstream quarantine {
  server wra03.ntex.com;
  server backup-wra.ntex.com backup;
}


location / {
    if ( $backend_server ) {
      add_header x-served-from $backend_server;
      proxy_pass http://$backend_Server;
      break;
    }

    add_header x-served-from "master";
    proxy_pass http://primary-first;

  }

@sachinhub sachinhub changed the title add frappe cmd and doctype in http header for better analytics and lo… HTTP request made through frappe.call - Add frappe cmd and doctype for analytics and load balancing Apr 8, 2019
@surajshetty3416 surajshetty3416 changed the title HTTP request made through frappe.call - Add frappe cmd and doctype for analytics and load balancing feat: Add frappe cmd and doctype to request headers for analytics and load balancing Apr 16, 2019
Co-Authored-By: sachinhub <sachin.mane@gmail.com>
@stale
Copy link

stale bot commented May 16, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed within a week if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.

@stale stale bot added the inactive label May 16, 2019
@sachinhub
Copy link
Contributor Author

@rmehta can this PR be merged?

@stale stale bot removed the inactive label May 20, 2019
@rmehta rmehta merged commit 91ce69b into frappe:develop May 20, 2019
@sachinhub
Copy link
Contributor Author

Thanks for merging. However, just noticed that changes suggested to use .get() does not work in JavaScript. Sent another merge request #7520

rmehta added a commit that referenced this pull request May 20, 2019
@surajshetty3416
Copy link
Member

surajshetty3416 commented May 20, 2019

@sachinhub Sorry for that suggestion. For some reason, I thought that it was a python file.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants