No description
Find a file
Ankush Menat d466578348
perf(gthread): Pin web workers to a single core (#28854)
Python's multithreaded model is _inefficient_ because of Global
Interpreter Lock (GIL). Any one thread of process can run at any given
time. Thus only valid use case for threads in Python are:

1. Hiding I/O latency by switching to a different thread.
2. Using compiled extensions that yield GIL for long enough time to do
   meaningful work in other threads.

Both of these are not as frequent as you'd imagine and gthread worker
with multiple threads often just end up contending on lock and waste
useful CPU cycles doing nothing. Pinning worker process to a core nearly
eliminates this contention wastage. This waste can be 5-10% and goes up
sharply with more threads.

E.g. FC typically has maxed out config of 24 workers which allows
"accepting" and working on 24 requests at a time. But that doesn't mean
24 requests are on CPU at any given time, that would require 24 physical
cores.

Why do this?

1. Context switching in threads is faster than switching process - fewer
   cache misses, fewer TLB misses etc.
2. The model is simple
    True parallelism = count(cores) = count(processes).
    Expected concurrency = count(processes) * count(threads).
3. This is far simpler to reason about than something like async
   executor model.
4. Ability to queue more requests than what can be handled is already
   implemented by `bind(2)` and `accept(2)` in kernel. There is no real
   benefit of accepting 1000 requests if you can only work on 20 of them
   at a time. This is because we do a lot of "work" in requests, it's
   not just issuing an external request and waiting for it.
5. We can achieve practically same concurrency as 24 workers with 4
   process x 6 threads. That's a lot of memory saved to run other useful
   things.

Caveats:
- This kind of pinning can potentially make Linux scheduler inefficient.
  I don't quite think it's going to be a big problem because there are
  plenty of other things to run which a core can steal from other core
  if it doesn't have enough work.
- Load balancing in single-server multi-bench setup. I *think* by nature
  of how `accept(2)` works, load balancing will still happen pretty much
  automatically. If certain core is overloaded, naturally other cores
  will reach `accept(2)` more frequently and take the load off of that
  core. This is something worth validating in practice by creating
  skewed affinities.
- This code is not NUMA-aware. None of our machines have NUMA nodes so,
  I am ignoring it. Don't use it if you have a NUMA setup.
- If new CPUs are hotplugged or existing ones are disabled then it can
  be inefficient (worse than current) until that worker auto-restarts (which
  happens after N requests in FC setup).

Ideal solution: We write userspace scheduler to implement
"soft-affinity" using Linux's new eBPF based sched_ext feature. That's
too much extra work but I'll consider this too at some point.

closes https://github.com/frappe/caffeine/issues/13
2024-12-22 16:59:13 +05:30
.github perf: Make frappe._dict great again (#28824) 2024-12-18 16:36:31 +05:30
billing fix: show trial plan based on is_trial_plan 2024-11-22 22:31:36 +05:30
cypress test: Scroll list_title into view 2024-10-21 12:17:04 +05:30
esbuild fix(esbuild): bug that caused apps to json to not get updated when --using-cached 2024-12-18 18:16:47 +05:30
frappe perf(gthread): Pin web workers to a single core (#28854) 2024-12-22 16:59:13 +05:30
realtime chore: linting 2024-06-21 17:26:16 +05:30
tests feat: add read only document mode 2024-10-02 12:02:52 +02:00
.coveragerc ci: Add Coveragerc (#22530) 2023-10-16 18:24:16 +05:30
.editorconfig chore: ignore helix folder 2024-08-29 14:28:52 +02:00
.eslintignore fix: Miscellaneous changes (#12343) 2021-02-08 12:05:37 +05:30
.eslintrc fix: All ESLint errors 2023-07-14 15:25:48 +05:30
.git-blame-ignore-revs fix(git-blame-ignore-revs): one character was missing from the hash 2024-12-05 13:26:43 +05:30
.gitignore fix: post install also install billing dependencies 2024-11-14 16:08:26 +05:30
.mergify.yml chore: disable mergify auto merges (#24825) 2024-02-09 13:59:40 +00:00
.pre-commit-config.yaml chore: bump ruff 2024-12-04 13:17:59 +05:30
.releaserc ci: better release notes generation (#19380) 2022-12-21 12:14:35 +05:30
.semgrepignore refactor!: Prefix all custom fieldnames created from Desk (#21355) 2023-06-19 18:22:36 +05:30
attributions.md refactor: Itenticon 2022-08-11 23:53:21 +05:30
babel_extractors.csv fix: extract translatable strings from the whole repo (#27848) 2024-09-24 15:55:46 +02:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2017-09-12 09:14:34 +05:30
codecov.yml ci: update codecov.yml flags 2023-01-10 13:19:12 +05:30
CODEOWNERS chore: simple codeowners 2023-07-25 13:06:49 +05:30
commitlint.config.js chore: add depr to commit types for deprecation decisions 2024-11-13 11:20:10 +01:00
crowdin.yml chore: update crowdin configuration (#25240) 2024-03-05 20:57:50 +05:30
cypress.config.js test: fix cypress tests (#26012) 2024-04-17 15:26:18 +00:00
generate_bootstrap_theme.js chore: remove eslint-disable* 2023-07-14 15:41:20 +05:30
hooks.md chore!: remove dead hooks app_icon & app_color 2022-05-10 14:41:01 +05:30
LICENSE chore: Update copyright until date to 2021 2021-09-03 12:19:15 +05:30
node_utils.js feat: prepare redis subsystem for unix domain socket connections 2024-03-29 10:12:19 +01:00
package.json refactor: revert package.json changes 2024-11-21 23:14:22 +05:30
pyproject.toml refactor: simplify bencher (#28694) 2024-12-07 14:10:03 +00:00
README.md chore: update readme (#28819) 2024-12-17 18:35:10 +00:00
SECURITY.md Update SECURITY.md 2023-01-10 16:49:44 +05:30
sider.yml chore(sider): add sider default config for flake8 + ignore tab errors (W191) (#12587) 2021-03-16 17:07:41 +05:30
socketio.js refactor: Split socketio in multiple logical files 2023-07-01 10:53:34 +05:30
yarn.lock chore(deps): bump nanoid from 3.3.7 to 3.3.8 2024-12-14 09:38:29 +00:00

Frappe Framework

Low Code Web Framework For Real World Applications, In Python And JavaScript

Hero Image

Frappe Framework

Full-stack web application framework that uses Python and MariaDB on the server side and a tightly integrated client side library. Built for ERPNext.

Motivation

Started in 2005, Frappe Framework was inspired by the Semantic Web. The "big idea" behind semantic web was of a framework that not only described how information is shown (like headings, body etc), but also what it means, like name, address etc.

By creating a web framework that allowed for easy definition of metadata, it made building complex applications easy. Applications usually designed around how users interact with a system, but not based on semantics of the underlying system. Applications built on semantics end up being much more consistent and extensible. The first application built on Framework was ERPNext, a beast with more than 700 object types. Framework is not for the light hearted - it is not the first thing you might want to learn if you are beginning to learn web programming, but if you are ready to do real work, then Framework is the right tool for the job.

Key Features

  • Full-Stack Framework: Frappe covers both front-end and back-end development, allowing developers to build complete applications using a single framework.

  • Built-in Admin Interface: Provides a pre-built, customizable admin dashboard for managing application data, reducing development time and effort.

  • Role-Based Permissions: Comprehensive user and role management system to control access and permissions within the application.

  • REST API: Automatically generated RESTful API for all models, enabling easy integration with other systems and services.

  • Customizable Forms and Views: Flexible form and view customization using server-side scripting and client-side JavaScript.

  • Report Builder: Powerful reporting tool that allows users to create custom reports without writing any code.

Screenshots

List View Form View Role Permission Manager

Production Setup

Managed Hosting

You can try Frappe Cloud, a simple, user-friendly and sophisticated open-source platform to host Frappe applications with peace of mind.

It takes care of installation, setup, upgrades, monitoring, maintenance and support of your Frappe deployments. It is a fully featured developer platform with an ability to manage and control multiple Frappe deployments.

Self Hosting

Docker

Prerequisites: docker, docker-compose, git. Refer Docker Documentation for more details on Docker setup.

Run following commands:

git clone https://github.com/frappe/frappe_docker
cd frappe_docker
docker compose -f pwd.yml up -d

After a couple of minutes, site should be accessible on your localhost port: 8080. Use below default login credentials to access the site.

  • Username: Administrator
  • Password: admin

See Frappe Docker for ARM based docker setup.

Development Setup

Manual Install

The Easy Way: our install script for bench will install all dependencies (e.g. MariaDB). See https://github.com/frappe/bench for more details.

New passwords will be created for the Frappe "Administrator" user, the MariaDB root user, and the frappe user (the script displays the passwords and saves them to ~/frappe_passwords.txt).

Local

To setup the repository locally follow the steps mentioned below:

  1. Setup bench by following the Installation Steps and start the server

    bench start
    
  2. In a separate terminal window, run the following commands:

    # Create a new site
    bench new-site frappe.dev
    
    # Map your site to localhost
    bench --site frappe.dev add-to-hosts
    
  3. Open the URL http://frappe.dev:8000/app in your browser, you should see the app running

Learning and community

  1. Frappe School - Learn Frappe Framework and ERPNext from the various courses by the maintainers or from the community.
  2. Official documentation - Extensive documentation for Frappe Framework.
  3. Discussion Forum - Engage with community of Frappe Framework users and service providers.
  4. buildwithhussain.dev - Watch Frappe Framework being used in the wild to build world-class web apps.

Contributing

  1. Issue Guidelines
  2. Report Security Vulnerabilities
  3. Pull Request Requirements