Slow Response for the /console/api/apps endpoint in SaaS Environment #22096

Closed
opened 2026-02-21 20:15:46 -05:00 by yindo · 1 comment
Owner

Originally created by @QuantumGhost on GitHub (Feb 5, 2026).

Originally assigned to: @QuantumGhost on GitHub.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.12.1

Cloud or Self Hosted

Cloud

Steps to reproduce

I have about 30 apps stored in one workspace in the cloud version. The the /console/api/apps endpoint takes about 50s to respond for that workspace.

Request URL: https://cloud.dify.ai/console/api/apps?page=1&limit=30&name=

Image

✔️ Expected Behavior

The response time should be in 1 second, ideally.

Actual Behavior

Slow response for /console/api/apps endpoint.

Originally created by @QuantumGhost on GitHub (Feb 5, 2026). Originally assigned to: @QuantumGhost on GitHub. ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.12.1 ### Cloud or Self Hosted Cloud ### Steps to reproduce I have about 30 apps stored in one workspace in the cloud version. The the `/console/api/apps` endpoint takes about 50s to respond for that workspace. Request URL: `https://cloud.dify.ai/console/api/apps?page=1&limit=30&name=` <img width="813" height="346" alt="Image" src="https://github.com/user-attachments/assets/dba1fa0c-b89f-45be-8290-6aea51c2b423" /> ### ✔️ Expected Behavior The response time should be in 1 second, ideally. ### ❌ Actual Behavior Slow response for `/console/api/apps` endpoint.
yindo added the 🐞 bugcloudperformance labels 2026-02-21 20:15:46 -05:00
yindo closed this issue 2026-02-21 20:15:46 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 5, 2026):

The slow response from the /console/api/apps endpoint is caused by N+1 query patterns in the backend code. When listing apps, the endpoint retrieves the main app records, but then for each app, it performs multiple additional database queries to fetch related data like model config, workflow, site, tenant, tags, and author name. With 30 apps, this results in dozens (or more) of extra queries, which quickly adds up and causes the long delay you’re seeing. This is a classic performance bottleneck in ORM-based APIs and is confirmed by the code for the endpoint and the App model properties (source, source).

To fix this, the endpoint should be refactored to use eager loading for all related data needed in the app list response, or batch-fetch related data before serializing the response. This will reduce the number of queries from dozens per request to just a few, dramatically improving performance. No recent merged pull requests address this specific issue yet (source).

If you want to confirm this bottleneck, you can enable SQL query logging or profiling in your environment and observe the number of queries executed for a single /console/api/apps call. For maintainers or contributors, the main code paths to review are the AppListApi.get() method, AppService.get_paginate_apps(), and the properties on the App model.

For reference, similar performance issues and architectural discussions are ongoing in the repo and discussions (discussion). Optimizing this endpoint will require code changes to avoid per-app database calls during serialization.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Feb 5, 2026): <!-- Answer --> The slow response from the `/console/api/apps` endpoint is caused by N+1 query patterns in the backend code. When listing apps, the endpoint retrieves the main app records, but then for each app, it performs multiple additional database queries to fetch related data like model config, workflow, site, tenant, tags, and author name. With 30 apps, this results in dozens (or more) of extra queries, which quickly adds up and causes the long delay you’re seeing. This is a classic performance bottleneck in ORM-based APIs and is confirmed by the code for the endpoint and the App model properties ([source](https://github.com/langgenius/dify/blob/7202a24bcf1a9aa02e9d5f5e419ff44e7d7d99a4/api/controllers/console/app/app.py#L468-L525), [source](https://github.com/langgenius/dify/blob/7202a24bcf1a9aa02e9d5f5e419ff44e7d7d99a4/api/models/model.py#L78-L316)). To fix this, the endpoint should be refactored to use eager loading for all related data needed in the app list response, or batch-fetch related data before serializing the response. This will reduce the number of queries from dozens per request to just a few, dramatically improving performance. No recent merged pull requests address this specific issue yet ([source](https://github.com/langgenius/dify/pull/30522)). If you want to confirm this bottleneck, you can enable SQL query logging or profiling in your environment and observe the number of queries executed for a single `/console/api/apps` call. For maintainers or contributors, the main code paths to review are the `AppListApi.get()` method, `AppService.get_paginate_apps()`, and the properties on the `App` model. For reference, similar performance issues and architectural discussions are ongoing in the repo and discussions ([discussion](https://github.com/langgenius/dify/discussions/29146)). Optimizing this endpoint will require code changes to avoid per-app database calls during serialization. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/b18977ec-2f61-4a2e-a323-26c3599b967a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/b18977ec-2f61-4a2e-a323-26c3599b967a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/b18977ec-2f61-4a2e-a323-26c3599b967a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/b18977ec-2f61-4a2e-a323-26c3599b967a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/b18977ec-2f61-4a2e-a323-26c3599b967a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/b18977ec-2f61-4a2e-a323-26c3599b967a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/b18977ec-2f61-4a2e-a323-26c3599b967a?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20slow%20response%20from%20the%20%60/console/api/apps%60%20endpoint%20is%20caused%20by%20N%2B1%20query%20patterns%20in%20the%20backend%20code.%20When%20listing%20apps%2C%20the%20endpoint%20retrieves%20the%20main%20app%20records%2C%20but%20then%20for%20each%20app%2C%20it%20performs%20multiple%20additional%20database%20queries%20to%20fetch%20related%20data%20like%20model%20config%2C%20workflow%2C%20site%2C%20tenant%2C%20tags%2C%20and%20author%20name.%20With%2030%20apps%2C%20this%20results%20in%20dozens%20%28or%20more%29%20of%20extra%20queries%2C%20which%20quickly%20adds%20up%20and%20causes%20the%20long%20delay%20you%E2%80%99re%20seeing.%20This%20is%20a%20classic%20performance%20bottleneck%20in%20ORM-based%20APIs%20and%20is%20confirmed%20by%20the%20code%20for%20the%20endpoint%20and%20the%20App%20model%20properties%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/7202a24bcf1a9aa02e9d5f5e419ff44e7d7d99a4/api/controllers/console/app/app.py%23L468-L525%29%2C%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/7202a24bcf1a9aa02e9d5f5e419ff44e7d7d99a4/api/models/model.py%23L78-L316%29%29.%0A%0ATo%20fix%20this%2C%20the%20endpoint%20should%20be%20refactored%20to%20use%20eager%20loading%20for%20all%20related%20data%20needed%20in%20the%20app%20list%20response%2C%20or%20batch-fetch%20related%20data%20before%20serializing%20the%20response.%20This%20will%20reduce%20the%20number%20of%20queries%20from%20dozens%20per%20request%20to%20just%20a%20few%2C%20dramatically%20improving%20performance.%20No%20recent%20merged%20pull%20requests%20address%20this%20specific%20issue%20yet%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/pull/30522%29%29.%0A%0AIf%20you%20want%20to%20confirm%20this%20bottleneck%2C%20you%20can%20enable%20SQL%20query%20logging%20or%20profiling%20in%20your%20environment%20and%20observe%20the%20number%20of%20queries%20executed%20for%20a%20single%20%60/console/api/apps%60%20call.%20For%20maintainers%20or%20contributors%2C%20the%20main%20code%20paths%20to%20review%20are%20the%20%60AppListApi.get%28%29%60%20method%2C%20%60AppService.get_paginate_apps%28%29%60%2C%20and%20the%20properties%20on%20the%20%60App%60%20model.%0A%0AFor%20reference%2C%20similar%20performance%20issues%20and%20architectural%20discussions%20are%20ongoing%20in%20the%20repo%20and%20discussions%20%28%5Bdiscussion%5D%28https%3A//github.com/langgenius/dify/discussions/29146%29%29.%20Optimizing%20this%20endpoint%20will%20require%20code%20changes%20to%20avoid%20per-app%20database%20calls%20during%20serialization.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31998)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#22096