Skip to content

Commit 1e9e81c

Browse files
committed
Modify Node.js scaling considerations
1 parent 07a070f commit 1e9e81c

File tree

3 files changed

+5
-29
lines changed

3 files changed

+5
-29
lines changed

articles/azure-functions/functions-best-practices.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,17 @@ Don't use verbose logging in production code, which has a negative performance i
8181

8282
### Use async code but avoid blocking calls
8383

84-
Asynchronous programming is a recommended best practice.
84+
Asynchronous programming is a recommended best practice, especially when blocking I/O operations are involved.
8585

8686
In C#, always avoid referencing the `Result` property or calling `Wait` method on a `Task` instance. This approach can lead to thread exhaustion.
8787

8888
[!INCLUDE [HTTP client best practices](../../includes/functions-http-client-best-practices.md)]
8989

9090
### Use multiple worker processes
9191

92-
For single-threaded runtimes like Python and Node.js, you can improve performance by using two additional methods:
92+
By default, any host instance for Functions uses a single worker process. To improve performance, especially with single-threaded runtimes like Python, use the [FUNCTIONS_WORKER_PROCESS_COUNT](functions-app-settings.md#functions_worker_process_count) to increase the number of worker processes per host (up to 10). Azure Functions then tries to evenly distribute simultaneous function invocations across these workers.
9393

94-
- Use async functions for blocking I/O operations.
95-
- Use the [FUNCTIONS_WORKER_PROCESS_COUNT](functions-app-settings.md#functions_worker_process_count) to increase the number of worker processes per host (up to 10).
96-
97-
For more information, see [Azure Functions Python developer guide - Scaling and concurrency](functions-reference-python.md#scaling-and-concurrency) and [Azure Functions Node.js developer guide - Scaling and concurrency](functions-reference-node.md#scaling-and-concurrency).
94+
The FUNCTIONS_WORKER_PROCESS_COUNT applies to each host that Functions creates when scaling out your application to meet demand.
9895

9996
### Receive messages in batch whenever possible
10097

articles/azure-functions/functions-reference-node.md

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -406,28 +406,7 @@ When you work with HTTP triggers, you can access the HTTP request and response o
406406

407407
By default, Azure Functions automatically monitors the load on your application and creates additional host instances for Node.js as needed. Functions uses built-in (not user configurable) thresholds for different trigger types to decide when to add instances, such the age of messages and queue size for QueueTrigger. For more information, see [How the consumption and premium plans work](functions-scale.md#how-the-consumption-and-premium-plans-work).
408408

409-
This scaling behavior is sufficient for many applications. Applications with any of the following characteristics, however, may not scale as effectively:
410-
411-
- The application needs to handle many concurrent invocations.
412-
- The application processes a large number of I/O events.
413-
- The application is I/O bound.
414-
415-
In such cases, you can improve performance further by employing async patterns and by using multiple language worker processes.
416-
417-
### Async
418-
419-
Because Node.js is a single-threaded runtime, a host instance for Node.js can process only one function invocation at a time. For applications that process a large number of I/O events and/or is I/O bound, you can improve performance by running functions asynchronously.
420-
421-
To run a function asynchronously, use the `async function` statement (available in Node.js 8 or later, which requires version 2.x of the Functions runtime).
422-
423-
```javascript
424-
async function myAsyncFunction(args) {
425-
// Code that uses await, etc.
426-
...
427-
}
428-
```
429-
430-
### Use multiple language worker processes
409+
This scaling behavior is sufficient for many Node.js applications. For CPU-bound applications, you can improve performance further by using multiple language worker processes.
431410

432411
By default, every Functions host instance has a single language worker process. You can increase the number of worker processes per host (up to 10) by using the [FUNCTIONS_WORKER_PROCESS_COUNT](functions-app-settings.md#functions_worker_process_count) application setting. Azure Functions then tries to evenly distribute simultaneous function invocations across these workers.
433412

articles/azure-functions/functions-scale.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Different triggers may also have different scaling limits as well as documented
158158

159159
There are many aspects of a function app that will impact how well it will scale, including host configuration, runtime footprint, and resource efficiency. For more information, see the [scalability section of the performance considerations article](functions-best-practices.md#scalability-best-practices). You should also be aware of how connections behave as your function app scales. For more information, see [How to manage connections in Azure Functions](manage-connections.md).
160160

161-
For additional information on scaling in Python and Node.js, which are single-threaded runtimes, see [Azure Functions Python developer guide - Scaling and concurrency](functions-reference-python.md#scaling-and-concurrency) and [Azure Functions Node.js developer guide - Scaling and concurrency](functions-reference-node.md#scaling-and-concurrency).
161+
For additional information on scaling in Python and Node.js, see [Azure Functions Python developer guide - Scaling and concurrency](functions-reference-python.md#scaling-and-concurrency) and [Azure Functions Node.js developer guide - Scaling and concurrency](functions-reference-node.md#scaling-and-concurrency).
162162

163163
### Billing model
164164

0 commit comments

Comments
 (0)