- Multiple CPU cores enables multiple threads.
- In past, it was complex with locks, took years to master.
- Today, it's simplified with ex. TPL (Task Parallel Library).
- Task Parallel Library (TPL)
- Extends System.Threading to simplify parallelism and concurrency.
- Dynamical scaling of degree of concurrency for maximum efficiency.
- Handles partitioning of work, scheduling threads in thread pool, cancellation, state management and more.
- A task holds metadata about the delegate: whether delegate has started/completed executing and it's resulting value.
- Use async-await to refactor TPL code.
- Useful for "gluing" together disparate systems (e.g. integration solutions)
- They can all define input, actions, conditions, and output.
- You can run each of them on a schedule or via a trigger.
- FaaS: Functions as a Service
- Support many languages such as C#, F#, Node.js, Java or PHP.
- Excellent for: data processing, integrating systems working with IoT, simple APIs/micro-services.
- Integrates with Azure and 3rd party services
- Integrations can trigger your function or serve as input/output.
- You can edit & compile & test (with request manipulations) & save in Portal.
- One function app can have many functions.
- In .NET
-
Provided by Azure WebJobs SDK.
-
json
specifies input/outputs.{ "disabled": false, "bindings":[ { "type": "queueTrigger", "direction": "in", "name": "message", "queueName": "announcementqueue", "connection":"StorageConnectionString" } ] }
-
Required fields: direction, name, type
-
C# script binds to "in" property as a method parameter:
public static void Run(string message, System.TraceWriter log) { log.Info($"New message: {message}"); }
-
-
Build & schedule & automate processes as workflows.
-
Scenarios: B2B, on-prem or cloud only or both, data/system integration, enterprise application integration (EAI).
-
You can integrate with on-premises using an On-premises Data Gateway.
- Download and install gateway
- Create Azure resource for gateway (on-premises data gateway)
- Connect to on-premises data
- Add a connector that supports on-premises connections, for example, SQL Server.
- Select Connect via on-premises data gateway.
-
Build visually in Logic Apps designer, available in Azure portal & Visual Studio. You can also use PowerShell & ARM templates for select tasks.
-
Describe in a json template:
{ "$schema":"https://schema.management.azure.com/schemas/2016-06-01/Microsoft.Logic.json", "contentVersion":"1.0.0.0", "parameters": { "uri": { "type": "string" } }, "triggers": { "request": { "type": "request", "kind": "http" } }, "actions": { "readData": { "type":"Http", "inputs": { "method":"GET"," uri":"@parameters('uri')" } } }, "outputs": {} }
- Blocking the calling thread during I/O
- Thread enters a wait state which other operations can't use it.
- Anti-pattern as it reduces performance & bad for vertical scalability.
- Asynchronous code
- Do not wait for I/O, transition long-running work other CPU cores.
- Allows servers to handle more requests & UIs to be more responsive.
- Use asynchronous interfaces for all data tier code, pair those with interfaces with asynchronous versions.
- E.g. if you have Entity Framework in controller, you'll need to rewrite code if you use another mapper or database in future => Use interfaces with async implementation.