đŸ•·ïž Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 197 (from laksa074)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

â„č Skipped - page is already crawled

📄
INDEXABLE
✅
CRAWLED
6 days ago
đŸ€–
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.2 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://thenewstack.io/python-threadpool-vs-multiprocessing/
Last Crawled2026-04-05 12:17:31 (6 days ago)
First Indexed2025-06-16 20:44:50 (9 months ago)
HTTP Status Code200
Meta TitleMultithreading vs. Multiprocessing in Python: A Beginner’s Guide to Concurrency and Parallelism
Meta DescriptionLearn the differences between concurrency, parallelism and async tasks in Python, and when to use ThreadPoolExecutor vs. ProcessPoolExecutor.
Meta Canonicalnull
Boilerpipe Text
Before we dive into multithreading and multiprocessing , let’s first cover some background info on concurrency , parallelism and asynchronous tasks . These three concepts are related but distinct. Let’s use a simple example to understand them: a mechanics shop. Concurrency happens when one mechanic works on several cars by switching between them. For example, the mechanic changes the oil in one car while waiting for a part for another. They don’t finish one car before starting the next, but they can’t do two tasks at exactly the same time. The tasks overlap in time but don’t happen simultaneously. Parallelism occurs when several mechanics work on different cars at the same time. One mechanic changes the oil, another replaces the brakes and another installs a battery. These tasks happen simultaneously, and can be completed at different times or at the same time because different people handle them. Asynchronous tasks work like this: You drop your car off and get a text when it is done. While the work takes place, you can do whatever you want: Go to work, the beach or do anything else, and the work still gets done in the background. Now to the tech explanations. The quick answer: Async tasks use concurrency, but not all concurrency is async. Parallelism stands apart and mainly relates to CPU usage. All parallelism involves concurrency, but not all concurrency achieves parallelism. Confusing? Let’s keep going! The long answer: Asynchronous tasks form a type of concurrency, usually for I/O-bound work. Tasks yield control while waiting, for example, for a file or network response. This allows other tasks to run. Concurrency covers running multiple tasks during the same period using threads, coroutines (async/await) or other methods. Parallelism means actually doing tasks simultaneously on multiple CPU cores. This approach fits CPU-bound work and often uses multiprocessing. TRENDING STORIES Why does this matter to Python programmers? Multiprocessing and Multithreading: Definitions and Uses Multithreading (concurrency) lets a single program create multiple threads sharing the same memory space. These threads run concurrently, switching between tasks to make progress. Multithreading works well for I/O-bound tasks. However, because of Python’s Global Interpreter Lock (GIL) , threads cannot run Python bytecode in true parallel on multiple CPU cores. Multiprocessing (parallelism) runs multiple processes independently. Each process has its own memory space and Python interpreter. This setup enables true parallelism by running tasks simultaneously on multiple CPU cores. Multiprocessing suits CPU-bound tasks because it bypasses the GIL limitation. Deciding between thread pools and process pools depends on your task type — whether it’s I/O-bound or CPU-bound. Why Do We Need Multithreading and Multiprocessing? Meet Python’s GIL The GIL is a mechanism in CPython , the standard Python implementation. It allows only one thread to execute Python bytecode at a time, even on multicore processors. Python introduced the GIL to simplify memory management and ensure thread safety. Because the GIL limits thread execution to one thread at a time: Threads cannot run Python bytecode in parallel, which reduces their effectiveness for CPU-bound tasks that require constant computation. This means: When you use multithreading, I/O-bound tasks can run efficiently because threads spend most of their time waiting on external resources like files, databases or network responses. The GIL only blocks actual Python bytecode execution. Multiprocessing enables true parallelism because each process has its own Python interpreter and GIL. This setup lets CPU-intensive tasks run across multiple cores. The GIL is why you use multithreading and multiprocessing to improve performance and responsiveness in Python applications when multiple tasks must execute at the same time. Syntax Python offers several ways to handle concurrency and parallelism. Two of the most common are `ThreadPoolExecutor` and `ProcessPoolExecutor`. Both provide powerful abstractions that simplify complex concurrency management. These tools come from the `concurrent.futures` module. They help you manage async tasks efficiently. `ThreadPoolExecutor` and `ProcessPoolExecutor` share the same interface. This similarity makes switching between them easy with minimal code changes. Using the `with` statement ensures threads or processes clean up properly when you finish. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor # threading with ThreadPoolExecutor(max_workers=4) as executor: results = executor.map(some_function, iterable) # multiprocessing with ProcessPoolExecutor(max_workers=4) as executor: results = executor.map(some_function, iterable) What Is Python’s ThreadPool? Definition and How It Works `ThreadPoolExecutor` acts like the mechanic quickly switching between multiple cars on a task-by-task basis. `ThreadPoolExecutor` executes tasks concurrently using threads within the same Python process. Because threads share memory, they create and switch quickly. When To Use `ThreadPoolExecutor` Use a thread pool when your application spends a lot of time on tasks that don’t need much CPU. Tasks that involve waiting suit thread pools best since threads can run while others wait. Examples include: HTTP requests Reading and writing to disk Database queries When you need to wait for user input Example: Using ThreadPoolExecutor for I/O-bound Tasks This example simulates fetching data from multiple URLs concurrently. Each `fetch_data` call waits for 2 seconds, but threads make the overall time much shorter than running sequentially. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters import time from concurrent.futures import ThreadPoolExecutor def fetch_data(url): print(f"Fetching from {url}") time.sleep(2) # Simulate delay return f"Data from {url}" urls = ['http://example.com/a', 'http://example.com/b', 'http://example.com/c'] with ThreadPoolExecutor(max_workers=3) as executor: results = executor.map(fetch_data, urls) for result in results: print(result) What Is Python Multiprocessing? Definition and How It Works ProcessPoolExecutor (multiprocessing) acts like having multiple mechanics, each working on their own car at the same time. Multiprocessing runs tasks in separate processes, each with its own memory space and Python interpreter. This allows true parallel execution on multiple CPU cores. Unlike threads, multiple mechanics work simultaneously without waiting. When To Use Multiprocessing Multiprocessing excels at tasks that you can spread across multiple cores. Use a process pool for tasks that consume a lot of CPU. These tasks might: Perform mathematical computations Process large datasets Process images and videos Example: Using ProcessPoolExecutor for CPU-Bound Tasks In the example below, each factorial calculation requires heavy CPU work. Running them in separate processes lets Python bypass the GIL and use multiple cores. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters import time from concurrent.futures import ProcessPoolExecutor def compute_factorial(n): if n == 0: return 1 else: return n * compute_factorial(n - 1) numbers = [20, 21, 22, 23] with ProcessPoolExecutor(max_workers=4) as executor: results = executor.map(compute_factorial, numbers) for result in results: print(result) Key Differences Between ThreadPool and Multiprocessing Let’s evaluate thread pools and multiprocessing based on important criteria to help you choose the right approach. Parallelism: Threads offer concurrency but not true parallelism due to the GIL. Processes provide real parallel execution. Memory sharing: Threads share data easily. Processes cannot share memory directly. Startup time: Threads start faster. Processes take longer due to the overhead of creating a new interpreter. Best use cases: Threads fit I/O-bound tasks like downloading files or accessing APIs. Processes fit CPU-bound tasks like number crunching or data transformation. When To Use `ThreadPoolExecutor` vs. `ProcessPoolExecutor` Choose `ThreadPoolExecutor` when: Your tasks involve a lot of waiting. You need lightweight concurrency. Memory sharing matters. Choose `ProcessPoolExecutor` when: Tasks require heavy CPU work. You want to use multiple CPU cores. You do not need to share memory between tasks. Performance Considerations and Benchmarks Measuring Execution Time for I/O-Bound Tasks In this example, we simulate I/O-bound tasks by sleeping for a few seconds. Using `ThreadPoolExecutor`, each task runs in its own thread. Threads overlap while waiting, so the overall runtime is much shorter than running tasks one after the other. This shows how threading improves performance for I/O-bound workloads. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters import time from concurrent.futures import ThreadPoolExecutor start = time.time() def io_task(n): time.sleep(n) return n with ThreadPoolExecutor() as executor: executor.map(io_task, [1, 2, 3, 4]) print("Total time (threads for I/O):", time.time() - start) The output will be the amount of time it takes for your system to complete this task. Measuring Execution Time for CPU-Bound Tasks Here, the function performs heavy arithmetic to simulate a CPU-bound task. These operations benefit from true parallelism. Using `ProcessPoolExecutor`, each task runs in a separate process on its own core if available. Processes bypass Python’s GIL, so they can execute Python bytecode in parallel. This reduces total runtime and improves efficiency for CPU-heavy workloads. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters import time from concurrent.futures import ProcessPoolExecutor start = time.time() def cpu_task(n): total = 0 for i in range(10**6): total += i * n return total with ProcessPoolExecutor() as executor: executor.map(cpu_task, [1, 2, 3, 4]) print("Total time (processes for CPU):", time.time() - start) The output will be the amount of time it takes for your system to complete this task. Common Pitfalls and Best Practices Avoiding Deadlocks in `ThreadPool` A deadlock happens when two or more threads wait for each other to release resources, causing all to stop progressing. Think of two mechanics holding tools that the other needs and refusing to let go. Work comes to a halt. You can avoid deadlocks by: Never blocking a thread indefinitely or waiting for it to complete Using the `with` context to ensure threads join automatically Being cautious with shared resources and protecting them with locks if needed Handling Memory Overhead in Multiprocessing Each process has its own memory space, so data does not share directly between processes. This separation increases memory overhead because large data structures duplicate across processes and consume more system memory. To manage memory: Avoid passing large data structures between processes when possible. Use tools like `multiprocessing.Manager` or shared memory constructs if you must share data to reduce duplication and memory use. Debugging ThreadPool and Multiprocessing Issues Debugging concurrency and parallelism poses challenges because threads and processes run independently and often at the same time. Issues like race conditions or hidden errors become harder to detect. Here are some tips: Thread issues, such as race conditions, can prove tricky to reproduce and fix. Use synchronization tools like `threading.Lock()` to control access to shared resources. Process issues might not show standard tracebacks in the main program. Use `multiprocessing.get_logger()` or add logging inside subprocesses to capture errors. For complex debugging and performance analysis, use profiling tools or higher-level frameworks like `joblib` or `dask` that offer better abstractions and diagnostics. Conclusion Understanding the differences between concurrency, parallelism and asynchronous tasks helps you determine which approach your task requires. In Python, `ThreadPoolExecutor` and `ProcessPoolExecutor` give you simple ways to handle threading and multiprocessing for I/O-bound and CPU-bound tasks efficiently. Knowing when to use each can save time, reduce complexity and improve performance. Group Created with Sketch.
Markdown
TNS OK SUBSCRIBE Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development. EMAIL ADDRESS REQUIRED SUBSCRIBE RESUBSCRIPTION REQUIRED It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription. RE-SUBSCRIBE The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our [Terms of Use](https://thenewstack.io/terms-of-use/) and [Privacy Policy](https://thenewstack.io/privacy-policy/). Welcome and thank you for joining The New Stack community\! Please answer a few simple questions to help us deliver the news and resources you are interested in. FIRST NAME REQUIRED LAST NAME REQUIRED COMPANY NAME REQUIRED COUNTRY REQUIRED ZIPCODE REQUIRED Great to meet you\! Tell us a bit about your job so we can cover the topics you find most relevant. What is your job level? REQUIRED Which of these most closely describes your job role? REQUIRED How many employees are in the organization you work with? REQUIRED What option best describes the type of organization you work for? REQUIRED Which of the following best describes your organization's primary industry? REQUIRED LINKEDIN PROFILE URL Welcome\! We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game. What’s next? Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups. Follow TNS on your favorite social media networks. Become a [TNS follower on LinkedIn](https://www.linkedin.com/company/the-new-stack). Check out [the latest featured and trending stories](https://thenewstack.io/) while you wait for your first TNS newsletter. PREV 1 of 2 NEXT VOXPOP As a JavaScript developer, what non-React tools do you use most often? ✓ Angular 0% ✓ Astro 0% ✓ Svelte 0% ✓ Vue.js 0% ✓ Other 0% ✓ I only use React 0% ✓ I don't use JavaScript 0% Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter: SUBMIT NEW! Try Stackie AI LOGIN ARCHITECTURE [Cloud Native Ecosystem](https://thenewstack.io/cloud-native/) [Containers](https://thenewstack.io/containers/) [Databases](https://thenewstack.io/databases/) [Edge Computing](https://thenewstack.io/edge-computing/) [Infrastructure as Code](https://thenewstack.io/infrastructure-as-code/) [Linux](https://thenewstack.io/linux/) [Microservices](https://thenewstack.io/microservices/) [Open Source](https://thenewstack.io/open-source/) [Networking](https://thenewstack.io/networking/) [Storage](https://thenewstack.io/storage/) ENGINEERING [AI](https://thenewstack.io/ai/) [AI Engineering](https://thenewstack.io/ai-engineering/) [API Management](https://thenewstack.io/api-management/) [Backend development](https://thenewstack.io/backend-development/) [Data](https://thenewstack.io/data/) [Frontend Development](https://thenewstack.io/frontend-development/) [Large Language Models](https://thenewstack.io/llm/) [Security](https://thenewstack.io/security/) [Software Development](https://thenewstack.io/software-development/) [WebAssembly](https://thenewstack.io/webassembly/) OPERATIONS [AI Operations](https://thenewstack.io/ai-operations/) [CI/CD](https://thenewstack.io/ci-cd/) [Cloud Services](https://thenewstack.io/cloud-services/) [DevOps](https://thenewstack.io/devops/) [Kubernetes](https://thenewstack.io/kubernetes/) [Observability](https://thenewstack.io/observability/) [Operations](https://thenewstack.io/operations/) [Platform Engineering](https://thenewstack.io/platform-engineering/) PROGRAMMING [C++](https://thenewstack.io/c/) [Developer tools](https://thenewstack.io/developer-tools/) [Go](https://thenewstack.io/go/) [Java](https://thenewstack.io/java/) [JavaScript](https://thenewstack.io/javascript/) [Programming Languages](https://thenewstack.io/programming-languages/) [Python](https://thenewstack.io/python/) [Rust](https://thenewstack.io/rust/) [TypeScript](https://thenewstack.io/typescript/) CHANNELS [Podcasts](https://thenewstack.io/podcasts/) [Ebooks](https://thenewstack.io/ebooks/) [Events](https://thenewstack.io/events/) [Webinars](https://thenewstack.io/webinars/) [Newsletter](https://thenewstack.io/newsletter/) [TNS RSS Feeds](https://thenewstack.io/rss-feeds/) THE NEW STACK [About / Contact](https://thenewstack.io/about-and-contact-info/) [Sponsors](https://thenewstack.io/sponsors/) [Advertise With Us](https://thenewstack.io/sponsorship/) [Contributions](https://thenewstack.io/contributions/) [PODCASTS](https://thenewstack.io/podcasts/) [EBOOKS](https://thenewstack.io/ebooks/) [EVENTS](https://thenewstack.io/events/) [WEBINARS](https://thenewstack.io/webinars/) [NEWSLETTER](https://thenewstack.io/newsletter/) [CONTRIBUTE](https://thenewstack.io/contributions/) [ARCHITECTURE](https://thenewstack.io/python-threadpool-vs-multiprocessing/) [ENGINEERING](https://thenewstack.io/python-threadpool-vs-multiprocessing/) [OPERATIONS](https://thenewstack.io/python-threadpool-vs-multiprocessing/) [PROGRAMMING](https://thenewstack.io/python-threadpool-vs-multiprocessing/) [Cloud Native Ecosystem](https://thenewstack.io/cloud-native/) [Containers](https://thenewstack.io/containers/) [Databases](https://thenewstack.io/databases/) [Edge Computing](https://thenewstack.io/edge-computing/) [Infrastructure as Code](https://thenewstack.io/infrastructure-as-code/) [Linux](https://thenewstack.io/linux/) [Microservices](https://thenewstack.io/microservices/) [Open Source](https://thenewstack.io/open-source/) [Networking](https://thenewstack.io/networking/) [Storage](https://thenewstack.io/storage/) [WebAssembly is now outperforming containers at the edge Mar 29th 2026 9:00am, by B. Cameron Gain](https://thenewstack.io/webassembly-component-model-future/) [How platform teams are eliminating a \$43,800 "hidden tax" on Kubernetes infrastructure Mar 28th 2026 4:09pm, by Janakiram MSV](https://thenewstack.io/virtual-clusters-kubernetes-cost-isolation/) [Solo.io launches agentevals to solve agentic AI's "biggest unsolved problem" Mar 28th 2026 6:00am, by Steven J. Vaughan-Nichols](https://thenewstack.io/soloio-agentevals-evaluates-ai-agents/) [Why WebAssembly won't replace Kubernetes but makes Helm more secure Mar 21st 2026 8:45am, by B. Cameron Gain](https://thenewstack.io/helm-webassembly-kubernetes-security/) [Why the ‘glorified host’ for AI is exactly the Kubernetes we need Mar 20th 2026 9:00am, by Danielle Cook](https://thenewstack.io/kubernetes-glorified-ai-host/) [Edera spent years calling KVM less secure. Here's why it changed its mind. Mar 25th 2026 2:22pm, by Steven J. Vaughan-Nichols](https://thenewstack.io/edera-adds-kvm-support/) [Minimus aims to solve one of open-source's long-festering problems Mar 24th 2026 3:00am, by Adrian Bridgwater](https://thenewstack.io/minimus-open-source-container-security/) [How to deploy Pi-Hole with Docker and stop ads on every device on your LAN Mar 23rd 2026 7:44am, by Jack Wallen](https://thenewstack.io/pihole-docker-network-adblocking/) [Chainguard has a fix for the open source packages your AI agents keep grabbing Mar 18th 2026 9:24am, by Darryl K. Taft](https://thenewstack.io/chainguard-repository-ai-agents/) [Chainguard thinks most DevOps teams are solving container security the hard way Mar 17th 2026 1:04pm, by Steven J. Vaughan-Nichols](https://thenewstack.io/chainguard-os-packages-containers/) [The reason your pgvector benchmark is lying to you Mar 27th 2026 5:00am, by Naina Ananthaswamy](https://thenewstack.io/why-pgvector-benchmarks-lie/) [Scaling Btrfs to petabytes in production: a 74% cost reduction story Mar 18th 2026 5:00am, by Motiejus JakĆĄtys](https://thenewstack.io/btrfs-petabyte-cost-reduction/) [The “files are all you need” debate misses what's actually happening in agent memory architecture Mar 13th 2026 5:00am, by Mikiko Bazeley](https://thenewstack.io/ai-agent-memory-architecture/) [With GridGain acquisition, MariaDB bets on in-memory computing and Apache Ignite Mar 10th 2026 6:47am, by Paul Sawers](https://thenewstack.io/with-gridgain-acquisition-mariadb-bets-on-in-memory-computing-and-apache-ignite/) [Moving AI apps from prototype to production requires enterprise-grade postgres infrastructure Mar 9th 2026 7:00am, by Meredith Shubel](https://thenewstack.io/ai-prototype-to-production-postgres/) [Edge-forward: Akamai eyes sweet spot between centralized & decentralized AI inference Apr 1st 2026 7:00am, by Adrian Bridgwater](https://thenewstack.io/akamai-edge-ai-inference/) [Developers are coding to a moving target, and nobody knows where AI lands next Mar 3rd 2026 7:33am, by Adrian Bridgwater](https://thenewstack.io/developers-coding-moving-target-ai/) [Cloudflare’s new Markdown support shows how the web is evolving for AI agents Mar 2nd 2026 4:30am, by David Eastman](https://thenewstack.io/intent-engineering-ai-agents/) [React Server Components Vulnerability Found Dec 6th 2025 7:00am, by Loraine Lawson](https://thenewstack.io/react-server-components-vulnerability-found/) [Kubernetes at the Edge: Lessons From GE HealthCare’s Edge Strategy Nov 24th 2025 10:00am, by Vicki Walker](https://thenewstack.io/kubernetes-at-the-edge-lessons-from-ge-healthcares-edge-strategy/) [The operational gap is real, and it's getting wider Mar 26th 2026 8:00am, by Yevgeny Pats](https://thenewstack.io/closing-cloud-operational-gap/) [Why "automated" infrastructure might cost more than you think Feb 24th 2026 4:00am, by Justyn Roberts](https://thenewstack.io/automated-infrastructure-hidden-costs/) [Why 40% of AI projects will be canceled by 2027 (and how to stay in the other 60%) Feb 13th 2026 6:00am, by Alex Drag](https://thenewstack.io/agentic-ai-connectivity-platform/) [Durable Execution: Build reliable software in an unreliable world Feb 2nd 2026 3:23pm, by Charles Humble](https://thenewstack.io/temporal-durable-execution-platform/) [Terraform challenger Formae expands to more clouds Jan 28th 2026 6:00am, by Joab Jackson](https://thenewstack.io/terraform-competitor-formae-expands-to-more-clouds/) [Sparky Linux 9 brings a rolling release to Debian Mar 30th 2026 8:00am, by Jack Wallen](https://thenewstack.io/sparky-linux-9-brings-a-rolling-release-to-debian/) [Edera spent years calling KVM less secure. Here's why it changed its mind. Mar 25th 2026 2:22pm, by Steven J. Vaughan-Nichols](https://thenewstack.io/edera-adds-kvm-support/) [Linux kernel scale is swamping an already-flawed CVE system Mar 20th 2026 4:30am, by Jed Salazar](https://thenewstack.io/linux-kernel-cve-system/) [Scaling Btrfs to petabytes in production: a 74% cost reduction story Mar 18th 2026 5:00am, by Motiejus JakĆĄtys](https://thenewstack.io/btrfs-petabyte-cost-reduction/) [Chainguard thinks most DevOps teams are solving container security the hard way Mar 17th 2026 1:04pm, by Steven J. Vaughan-Nichols](https://thenewstack.io/chainguard-os-packages-containers/) [Tetrate launches open source marketplace to simplify Envoy adoption Mar 11th 2026 10:52am, by Adrian Bridgwater](https://thenewstack.io/tetrate-built-on-envoy/) [OpenTelemetry roadmap: Sampling rates and collector improvements ahead Feb 24th 2026 11:00am, by B. Cameron Gain](https://thenewstack.io/opentelemetry-roadmap-sampling-rates-and-collector-improvements-ahead/) [Merging To Test Is Killing Your Microservices Velocity Dec 16th 2025 7:00am, by Arjun Iyer](https://thenewstack.io/merging-to-test-is-killing-your-microservices-velocity/) [IBM’s Confluent Acquisition Is About Event-Driven AI Dec 11th 2025 6:00am, by Joab Jackson](https://thenewstack.io/ibms-confluent-acquisition-is-about-event-driven-ai/) [Deploy Agentic AI Workflows With Kubernetes and Terraform Nov 26th 2025 9:00am, by Oladimeji Sowole](https://thenewstack.io/deploy-agentic-ai-workflows-with-kubernetes-and-terraform/) [Portkey open-sources its AI gateway after processing 2 trillion tokens a day Mar 31st 2026 3:53pm, by Adrian Bridgwater](https://thenewstack.io/portkey-gateway-open-source/) [Ollama taps Apple’s MLX framework to make local AI models faster on Macs Mar 31st 2026 8:00am, by Paul Sawers](https://thenewstack.io/ollama-taps-apples-mlx/) [96% of codebases rely on open source, and AI slop is putting them at risk Mar 29th 2026 6:00am, by Bill Doerrfeld](https://thenewstack.io/ai-slop-open-source/) [Gitleaks creator returns with Betterleaks, an open source secrets scanner for the agentic era Mar 27th 2026 11:00am, by Paul Sawers](https://thenewstack.io/betterleaks-open-source-secret-scanner/) [How TeamPCP turned Aqua Security's own Trivy scanner into a weapon against millions of developers Mar 27th 2026 10:00am, by Steven J. Vaughan-Nichols](https://thenewstack.io/teampcp-trivy-supply-chain-attack/) [How to deploy Pi-Hole with Docker and stop ads on every device on your LAN Mar 23rd 2026 7:44am, by Jack Wallen](https://thenewstack.io/pihole-docker-network-adblocking/) [Why flat Kubernetes networks fail at scale Mar 20th 2026 7:00am, by Reza Ramezanpour](https://thenewstack.io/kubernetes-network-security-hierarchies/) [GSMA Open Gateway offers developers one API for 300+ mobile networks Mar 4th 2026 10:26am, by Adrian Bridgwater](https://thenewstack.io/gsma-open-gateway-developers/) [How Homepage simplifies monitoring your self-hosted services Feb 6th 2026 8:00am, by Jack Wallen](https://thenewstack.io/how-homepage-simplifies-monitoring-your-self-hosted-services/) [S3 is the new network: Rethinking data architecture for the cloud era Feb 2nd 2026 4:00am, by Max Liu](https://thenewstack.io/tidb-x-open-source-database/) [Scaling Btrfs to petabytes in production: a 74% cost reduction story Mar 18th 2026 5:00am, by Motiejus JakĆĄtys](https://thenewstack.io/btrfs-petabyte-cost-reduction/) [What is KubeVirt and why it’s growing Mar 17th 2026 9:00am, by Tiago Castro](https://thenewstack.io/kubevirt-live-migration-mayastor/) [S3 is the new network: Rethinking data architecture for the cloud era Feb 2nd 2026 4:00am, by Max Liu](https://thenewstack.io/tidb-x-open-source-database/) [Agoda’s secret to 50x scale: Getting the database basics right Jan 28th 2026 7:00am, by Cynthia Dunlop](https://thenewstack.io/agodas-secret-to-50x-scale-getting-the-database-basics-right/) [Chainguard EmeritOSS backs MinIO, other orphaned projects Jan 27th 2026 6:15am, by Steven J. Vaughan-Nichols](https://thenewstack.io/chainguard-emeritoss-backs-minio-other-orphaned-projects/) [AI](https://thenewstack.io/ai/) [AI Engineering](https://thenewstack.io/ai-engineering/) [API Management](https://thenewstack.io/api-management/) [Backend development](https://thenewstack.io/backend-development/) [Data](https://thenewstack.io/data/) [Frontend Development](https://thenewstack.io/frontend-development/) [Large Language Models](https://thenewstack.io/llm/) [Security](https://thenewstack.io/security/) [Software Development](https://thenewstack.io/software-development/) [WebAssembly](https://thenewstack.io/webassembly/) [How to integrate VS Code with Ollama for local AI assistance](https://thenewstack.io/how-to-integrate-vs-code-with-ollama-for-local-ai-assistance/) Apr 1st 2026 8:00am, by [Jack Wallen](https://thenewstack.io/author/jack-wallen/ "Posts by Jack Wallen") [Claude Code users say they’re hitting usage limits faster than normal](https://thenewstack.io/claude-code-usage-limits/) Mar 31st 2026 2:30pm, by [Meredith Shubel](https://thenewstack.io/author/mshubel/ "Posts by Meredith Shubel") [Ollama taps Apple’s MLX framework to make local AI models faster on Macs](https://thenewstack.io/ollama-taps-apples-mlx/) Mar 31st 2026 8:00am, by [Paul Sawers](https://thenewstack.io/author/paul-sawers/ "Posts by Paul Sawers") [Kelsey Hightower at KubeCon 2026: "Everyone is a junior engineer when it comes to AI"](https://thenewstack.io/hightower-ai-open-source-kubecon/) Mar 30th 2026 2:45pm, by [Jennifer Riggins](https://thenewstack.io/author/jennifer-riggins/ "Posts by Jennifer Riggins") [Microsoft's Copilot makes Anthropic's Claude and OpenAI's GPT team up](https://thenewstack.io/microsofts-copilot-llm-team/) Mar 30th 2026 9:00am, by [Frederic Lardinois](https://thenewstack.io/author/frederic-lardinois/ "Posts by Frederic Lardinois") [AI accelerates modernization, but don’t leave human devs behind](https://thenewstack.io/ai-modernization-human-developers/) Mar 31st 2026 12:00pm, by [Matthew Weier O’Phinney](https://thenewstack.io/author/matthew-weier-ophinney/ "Posts by Matthew Weier O’Phinney") [Build it yourself: A data pipeline that trains a real model](https://thenewstack.io/data-pipelines-serve-ai/) Mar 28th 2026 9:00am, by [Jessica Wachtel](https://thenewstack.io/author/jessica-wachtel/ "Posts by Jessica Wachtel") [Why online stores keep showing the wrong products — and why tensors fix it](https://thenewstack.io/tensor-ranking-product-discovery/) Mar 25th 2026 6:00am, by [Tim Young](https://thenewstack.io/author/tim-young/ "Posts by Tim Young") [OpenClaw's biggest security flaw is why Jentic Mini exists](https://thenewstack.io/openclaw-is-a-security-mess-jentic-wants-to-fix-it/) Mar 25th 2026 5:00am, by [Darryl K. Taft](https://thenewstack.io/author/darryl-taft/ "Posts by Darryl K. Taft") [Why most AI projects fail after the demo actually works](https://thenewstack.io/ai-demo-to-production/) Mar 25th 2026 4:00am, by [Oladimeji Sowole](https://thenewstack.io/author/oladimeji-sowole/ "Posts by Oladimeji Sowole") [MCP is everywhere, but don't panic. Here's why your existing APIs still matter.](https://thenewstack.io/api-mcp-agent-integration/) Mar 23rd 2026 5:00am, by [Camille Crowell-Lee](https://thenewstack.io/author/camille-crowell-lee/ "Posts by Camille Crowell-Lee") and [Morgan Fine](https://thenewstack.io/author/morgan-fine/ "Posts by Morgan Fine") [Before you let AI agents loose, you’d better know what they’re capable of](https://thenewstack.io/risk-mitigation-agentic-ai/) Mar 12th 2026 1:22pm, by [Charles Humble](https://thenewstack.io/author/charles-humble/ "Posts by Charles Humble") [GSMA Open Gateway offers developers one API for 300+ mobile networks](https://thenewstack.io/gsma-open-gateway-developers/) Mar 4th 2026 10:26am, by [Adrian Bridgwater](https://thenewstack.io/author/adrian-bridgwater/ "Posts by Adrian Bridgwater") [Your AI strategy is built on layers of API sediment](https://thenewstack.io/ai-strategy-api-sediment/) Feb 17th 2026 9:37am, by [Charles Humble](https://thenewstack.io/author/charles-humble/ "Posts by Charles Humble") [Solving the Problems That Accompany API Sprawl With AI](https://thenewstack.io/solving-the-problems-that-accompany-api-sprawl-with-ai/) Jan 15th 2026 1:00pm, by [Heather Joslyn](https://thenewstack.io/author/hjoslyn/ "Posts by Heather Joslyn") [Backend Development in 2026: What's Changed, What Matters, and What to Learn Next](https://thenewstack.io/introduction-to-backend-development/) Mar 19th 2026 11:37am, by [TNS Staff](https://thenewstack.io/author/tns-staff/ "Posts by TNS Staff") [How To Get DNS Right: A Guide to Common Failure Modes](https://thenewstack.io/how-to-get-dns-right-a-guide-to-common-failure-modes/) Dec 24th 2025 8:00am, by [Sheldon Pereira](https://thenewstack.io/author/sheldon-pereira/ "Posts by Sheldon Pereira") and [Denton Chikura](https://thenewstack.io/author/denton-chikura/ "Posts by Denton Chikura") [Combining Rust and Python for High-Performance AI Systems](https://thenewstack.io/combining-rust-and-python-for-high-performance-ai-systems/) Dec 3rd 2025 1:00pm, by [Zziwa Raymond Ian](https://thenewstack.io/author/zziwa-raymond/ "Posts by Zziwa Raymond Ian") [How MCP Uses Streamable HTTP for Real-Time AI Tool Interaction](https://thenewstack.io/how-mcp-uses-streamable-http-for-real-time-ai-tool-interaction/) Aug 18th 2025 10:34am, by [Janakiram MSV](https://thenewstack.io/author/janakiram/ "Posts by Janakiram MSV") [A Backend for Frontend: Watt for Node.js Simplifies Operations](https://thenewstack.io/a-backend-for-frontend-watt-for-node-js-simplifies-operations/) Aug 14th 2025 6:00am, by [Loraine Lawson](https://thenewstack.io/author/loraine-lawson/ "Posts by Loraine Lawson") [Build it yourself: A data pipeline that trains a real model](https://thenewstack.io/data-pipelines-serve-ai/) Mar 28th 2026 9:00am, by [Jessica Wachtel](https://thenewstack.io/author/jessica-wachtel/ "Posts by Jessica Wachtel") [Fivetran donates its SQLMesh data transformation framework to the Linux Foundation](https://thenewstack.io/fivetran-donates-sqlmesh-lf/) Mar 25th 2026 7:39am, by [Frederic Lardinois](https://thenewstack.io/author/frederic-lardinois/ "Posts by Frederic Lardinois") [Ex-Snowflake engineers say there's a blind spot in data engineering — so they built Tower to fix it](https://thenewstack.io/tower-python-data-pipelines/) Mar 15th 2026 7:00am, by [Paul Sawers](https://thenewstack.io/author/paul-sawers/ "Posts by Paul Sawers") [Why the "bible" of data systems is getting a massive rewrite for 2026](https://thenewstack.io/data-intensive-applications-rewrite-2026/) Mar 4th 2026 5:00am, by [Cynthia Dunlop](https://thenewstack.io/author/cynthiadunlop/ "Posts by Cynthia Dunlop") [How to clone a drive to an image with Clonezilla](https://thenewstack.io/how-to-clone-a-drive-to-an-image-with-clonezilla/) Mar 3rd 2026 1:00pm, by [Jack Wallen](https://thenewstack.io/author/jack-wallen/ "Posts by Jack Wallen") [WebMCP turns any Chrome web page into an MCP server for AI agents](https://thenewstack.io/webmcp-chrome-ai-agents/) Mar 17th 2026 11:50am, by [David Eastman](https://thenewstack.io/author/david-eastman/ "Posts by David Eastman") [Confluent adds A2A support, anomaly detection, and Queues for Kafka in major platform update](https://thenewstack.io/confluent-kafka-a2a-agents/) Mar 3rd 2026 10:21am, by [Jelani Harper](https://thenewstack.io/author/jelani-harper/ "Posts by Jelani Harper") [Google's Chrome browser moves to a two-week release cycle](https://thenewstack.io/chrome-two-week-releases/) Mar 3rd 2026 9:00am, by [Frederic Lardinois](https://thenewstack.io/author/frederic-lardinois/ "Posts by Frederic Lardinois") [Meta gave React its own foundation. But it's not letting go just yet.](https://thenewstack.io/react-foundation-open-source-governance/) Mar 3rd 2026 4:00am, by [Paul Sawers](https://thenewstack.io/author/paul-sawers/ "Posts by Paul Sawers") [The shift left hangover: Why modern platforms are shifting down to cure developer fatigue](https://thenewstack.io/shift-left-hangover-steve-corndell/) Jan 30th 2026 6:22pm, by [Steve Corndell](https://thenewstack.io/author/steve-corndell/ "Posts by Steve Corndell") [Why most AI projects fail after the demo actually works](https://thenewstack.io/ai-demo-to-production/) Mar 25th 2026 4:00am, by [Oladimeji Sowole](https://thenewstack.io/author/oladimeji-sowole/ "Posts by Oladimeji Sowole") [IBM, Red Hat, and Google just donated a Kubernetes blueprint for LLM inference to the CNCF](https://thenewstack.io/llm-d-cncf-kubernetes-inference/) Mar 24th 2026 8:20am, by [Steven J. Vaughan-Nichols](https://thenewstack.io/author/sjvn/ "Posts by Steven J. Vaughan-Nichols") [Andrej Karpathy's 630-line Python script ran 50 experiments overnight without any human input](https://thenewstack.io/karpathy-autonomous-experiment-loop/) Mar 14th 2026 5:00am, by [Janakiram MSV](https://thenewstack.io/author/janakiram/ "Posts by Janakiram MSV") ["Self-healing" IT? HPE research explores how AI-trained models can catch silent infrastructure failures](https://thenewstack.io/hpe-self-healing-ai-infrastructure/) Mar 11th 2026 9:37am, by [Jennifer Riggins](https://thenewstack.io/author/jennifer-riggins/ "Posts by Jennifer Riggins") [How context rot drags down AI and LLM results for enterprises, and how to fix it](https://thenewstack.io/context-rot-enterprise-ai-llms/) Mar 9th 2026 9:00am, by [Todd R. Weiss](https://thenewstack.io/author/todd-r-weiss/ "Posts by Todd R. Weiss") [Inside Claude Code's leaked source: swarms, daemons, and 44 features Anthropic kept behind flags](https://thenewstack.io/claude-code-source-leak/) Apr 1st 2026 7:23am, by [Janakiram MSV](https://thenewstack.io/author/janakiram/ "Posts by Janakiram MSV") [Nvidia's NemoClaw has three layers of agent security. None of them solve the real problem.](https://thenewstack.io/nvidia-nemoclaw-openclaw-security/) Mar 28th 2026 9:30am, by [David Eastman](https://thenewstack.io/author/david-eastman/ "Posts by David Eastman") [Gitleaks creator returns with Betterleaks, an open source secrets scanner for the agentic era](https://thenewstack.io/betterleaks-open-source-secret-scanner/) Mar 27th 2026 11:00am, by [Paul Sawers](https://thenewstack.io/author/paul-sawers/ "Posts by Paul Sawers") [How TeamPCP turned Aqua Security's own Trivy scanner into a weapon against millions of developers](https://thenewstack.io/teampcp-trivy-supply-chain-attack/) Mar 27th 2026 10:00am, by [Steven J. Vaughan-Nichols](https://thenewstack.io/author/sjvn/ "Posts by Steven J. Vaughan-Nichols") [OpenClaw's biggest security flaw is why Jentic Mini exists](https://thenewstack.io/openclaw-is-a-security-mess-jentic-wants-to-fix-it/) Mar 25th 2026 5:00am, by [Darryl K. Taft](https://thenewstack.io/author/darryl-taft/ "Posts by Darryl K. Taft") [How to solve the AI paradox in software development with intelligent orchestration](https://thenewstack.io/solve-ai-paradox-orchestration/) Mar 31st 2026 12:14pm, by [Manav Khurana](https://thenewstack.io/author/manav-khurana/ "Posts by Manav Khurana") [AI accelerates modernization, but don’t leave human devs behind](https://thenewstack.io/ai-modernization-human-developers/) Mar 31st 2026 12:00pm, by [Matthew Weier O’Phinney](https://thenewstack.io/author/matthew-weier-ophinney/ "Posts by Matthew Weier O’Phinney") [Kelsey Hightower at KubeCon 2026: "Everyone is a junior engineer when it comes to AI"](https://thenewstack.io/hightower-ai-open-source-kubecon/) Mar 30th 2026 2:45pm, by [Jennifer Riggins](https://thenewstack.io/author/jennifer-riggins/ "Posts by Jennifer Riggins") [WebAssembly is now outperforming containers at the edge](https://thenewstack.io/webassembly-component-model-future/) Mar 29th 2026 9:00am, by [B. Cameron Gain](https://thenewstack.io/author/bruce-gain/ "Posts by B. Cameron Gain") [96% of codebases rely on open source, and AI slop is putting them at risk](https://thenewstack.io/ai-slop-open-source/) Mar 29th 2026 6:00am, by [Bill Doerrfeld](https://thenewstack.io/author/bill-doerrfeld/ "Posts by Bill Doerrfeld") [Edge-forward: Akamai eyes sweet spot between centralized & decentralized AI inference](https://thenewstack.io/akamai-edge-ai-inference/) Apr 1st 2026 7:00am, by [Adrian Bridgwater](https://thenewstack.io/author/adrian-bridgwater/ "Posts by Adrian Bridgwater") [WebAssembly is now outperforming containers at the edge](https://thenewstack.io/webassembly-component-model-future/) Mar 29th 2026 9:00am, by [B. Cameron Gain](https://thenewstack.io/author/bruce-gain/ "Posts by B. Cameron Gain") [WebAssembly could solve AI agents' most dangerous security gap](https://thenewstack.io/webassembly-sandboxing-ai-agents/) Mar 24th 2026 9:01am, by [B. Cameron Gain](https://thenewstack.io/author/bruce-gain/ "Posts by B. Cameron Gain") [How WebAssembly plugins simplify Kubernetes extensibility](https://thenewstack.io/how-webassembly-plugins-simplify-kubernetes-extensibility/) Mar 3rd 2026 2:00pm, by [B. Cameron Gain](https://thenewstack.io/author/bruce-gain/ "Posts by B. Cameron Gain") [WebAssembly is everywhere. Here's how it works](https://thenewstack.io/webassembly-is-everywhere-heres-how-it-works/) Feb 25th 2026 11:00am, by [Jessica Wachtel](https://thenewstack.io/author/jessica-wachtel/ "Posts by Jessica Wachtel") [AI Operations](https://thenewstack.io/ai-operations/) [CI/CD](https://thenewstack.io/ci-cd/) [Cloud Services](https://thenewstack.io/cloud-services/) [DevOps](https://thenewstack.io/devops/) [Kubernetes](https://thenewstack.io/kubernetes/) [Observability](https://thenewstack.io/observability/) [Operations](https://thenewstack.io/operations/) [Platform Engineering](https://thenewstack.io/platform-engineering/) [JetBrains: AI agents are about to repeat the cloud ROI crisis](https://thenewstack.io/jetbrains-central-ai-agents/) Mar 31st 2026 4:02pm, by Darryl K. Taft [HPE's AI agents cut root cause analysis time in half](https://thenewstack.io/hpes-ai-agents-cut-root-cause-analysis-time-in-half/) Mar 25th 2026 7:14am, by Jennifer Riggins [Why most AI projects fail after the demo actually works](https://thenewstack.io/ai-demo-to-production/) Mar 25th 2026 4:00am, by Oladimeji Sowole [From pillars to platform: How open observability data is changing the industry](https://thenewstack.io/open-observability-ai-platforms/) Mar 20th 2026 6:00am, by Ted Young [Building a Kubernetes-native pattern for AI infrastructure at scale](https://thenewstack.io/kubernetes-native-ai-infrastructure/) Mar 19th 2026 5:00am, by Sachi Desai [How TeamPCP turned Aqua Security's own Trivy scanner into a weapon against millions of developers](https://thenewstack.io/teampcp-trivy-supply-chain-attack/) Mar 27th 2026 10:00am, by Steven J. Vaughan-Nichols [Enterprise dev teams are about to hit a wall. And CI pipelines can't save them.](https://thenewstack.io/ai-agent-validation-bottleneck/) Mar 26th 2026 7:00am, by Anirudh Ramanathan [This simple infrastructure gap is holding back AI productivity](https://thenewstack.io/this-simple-infrastructure-gap-is-holding-back-ai-productivity/) Feb 22nd 2026 8:00am, by Charlotte Fleming [Ramp’s Inspect shows closed-loop AI agents are software’s future](https://thenewstack.io/ramps-inspect-shows-closed-loop-ai-agents-are-softwares-future/) Jan 29th 2026 11:00am, by Arjun Iyer [QCon chat: Is agentic AI killing continuous integration?](https://thenewstack.io/qcon-chat-is-agentic-ai-killing-continuous-integration/) Jan 27th 2026 6:00am, by Joab Jackson [A practical guide to the 6 categories of AI cloud infrastructure in 2026](https://thenewstack.io/ai-cloud-taxonomy-2026/) Mar 15th 2026 5:00am, by Janakiram MSV [Runpod report: Qwen has overtaken Meta's Llama as the most-deployed self-hosted LLM](https://thenewstack.io/runpod-ai-infrastructure-reality/) Mar 12th 2026 6:00am, by Adrian Bridgwater [Snowflake Cortex Code CLI adds dbt and Apache Airflow support for AI-powered data pipelines](https://thenewstack.io/snowflake-cortex-code-dbt-airflow/) Mar 8th 2026 6:00am, by Jelani Harper [Databases weren’t built for agent sprawl – SurrealDB wants to fix it](https://thenewstack.io/surrealdb-3-ai-agents/) Feb 24th 2026 2:07pm, by Paul Sawers [Rising identity complexity: How CISOs can prevent it from becoming an attacker’s roadmap](https://thenewstack.io/ciso-identity-complexity-strategy/) Feb 19th 2026 12:47pm, by Jay Reddy [One developer, team power: The future of AI-driven DevSecOps](https://thenewstack.io/future-ai-driven-devsecops/) Mar 5th 2026 2:29pm, by Bryan Ross [Observability platform migration guide: Prometheus, OpenTelemetry, and Fluent Bit](https://thenewstack.io/observability-platform-migration-guide/) Feb 26th 2026 7:28am, by Katie Greenley [Most platform teams build products, but they don’t know it](https://thenewstack.io/internal-platforms-are-products/) Feb 24th 2026 9:00am, by Oleg Danilyuk [Why "automated" infrastructure might cost more than you think](https://thenewstack.io/automated-infrastructure-hidden-costs/) Feb 24th 2026 4:00am, by Justyn Roberts [The essential shift every ITOps leader must make to survive an unrelenting stream of incidents](https://thenewstack.io/modernizing-itops-incident-management/) Feb 19th 2026 1:46pm, by Ariel Russo [How platform teams are eliminating a \$43,800 "hidden tax" on Kubernetes infrastructure](https://thenewstack.io/virtual-clusters-kubernetes-cost-isolation/) Mar 28th 2026 4:09pm, by Janakiram MSV [Your Kubernetes isn't ready for AI workloads, and drift is the reason](https://thenewstack.io/ai-workloads-kubernetes-infrastructure-drift/) Mar 25th 2026 8:43am, by TNS Staff [Broadcom donates Velero to CNCF — and it could reshape how Kubernetes users handle backup and disaster recovery](https://thenewstack.io/broadcom-velero-cncf-kubernetes/) Mar 24th 2026 8:38am, by B. Cameron Gain [IBM, Red Hat, and Google just donated a Kubernetes blueprint for LLM inference to the CNCF](https://thenewstack.io/llm-d-cncf-kubernetes-inference/) Mar 24th 2026 8:20am, by Steven J. Vaughan-Nichols [Why WebAssembly won't replace Kubernetes but makes Helm more secure](https://thenewstack.io/helm-webassembly-kubernetes-security/) Mar 21st 2026 8:45am, by B. Cameron Gain [Solo.io launches agentevals to solve agentic AI's "biggest unsolved problem"](https://thenewstack.io/soloio-agentevals-evaluates-ai-agents/) Mar 28th 2026 6:00am, by Steven J. Vaughan-Nichols [From pillars to platform: How open observability data is changing the industry](https://thenewstack.io/open-observability-ai-platforms/) Mar 20th 2026 6:00am, by Ted Young [Sampling: the philosopher's stone of distributed tracing](https://thenewstack.io/distributed-tracing-sampling-opentelemetry/) Mar 19th 2026 8:00am, by Michele Mancioppi [Why your observability bill keeps growing (and it's not your vendor's fault)](https://thenewstack.io/why-observability-bills-grow/) Mar 18th 2026 4:00am, by Juraci PaixĂŁo Kröhling [Why agentic AI stalls in production — and how a control plane fixes it](https://thenewstack.io/agentic-ai-control-plane-production/) Mar 17th 2026 6:00am, by TNS Staff [Edge-forward: Akamai eyes sweet spot between centralized & decentralized AI inference](https://thenewstack.io/akamai-edge-ai-inference/) Apr 1st 2026 7:00am, by Adrian Bridgwater [The operational gap is real, and it's getting wider](https://thenewstack.io/closing-cloud-operational-gap/) Mar 26th 2026 8:00am, by Yevgeny Pats [HPE's AI agents cut root cause analysis time in half](https://thenewstack.io/hpes-ai-agents-cut-root-cause-analysis-time-in-half/) Mar 25th 2026 7:14am, by Jennifer Riggins [WebAssembly could solve AI agents' most dangerous security gap](https://thenewstack.io/webassembly-sandboxing-ai-agents/) Mar 24th 2026 9:01am, by B. Cameron Gain [Kubernetes co-founder Brendan Burns: AI-generated code will become as invisible as assembly](https://thenewstack.io/ai-generated-code-invisible/) Mar 24th 2026 7:20am, by Frederic Lardinois [How to solve the AI paradox in software development with intelligent orchestration](https://thenewstack.io/solve-ai-paradox-orchestration/) Mar 31st 2026 12:14pm, by Manav Khurana [How platform teams are eliminating a \$43,800 "hidden tax" on Kubernetes infrastructure](https://thenewstack.io/virtual-clusters-kubernetes-cost-isolation/) Mar 28th 2026 4:09pm, by Janakiram MSV [The operational gap is real, and it's getting wider](https://thenewstack.io/closing-cloud-operational-gap/) Mar 26th 2026 8:00am, by Yevgeny Pats [Enterprise dev teams are about to hit a wall. And CI pipelines can't save them.](https://thenewstack.io/ai-agent-validation-bottleneck/) Mar 26th 2026 7:00am, by Anirudh Ramanathan [Your Kubernetes isn't ready for AI workloads, and drift is the reason](https://thenewstack.io/ai-workloads-kubernetes-infrastructure-drift/) Mar 25th 2026 8:43am, by TNS Staff [C++](https://thenewstack.io/c/) [Developer tools](https://thenewstack.io/developer-tools/) [Go](https://thenewstack.io/go/) [Java](https://thenewstack.io/java/) [JavaScript](https://thenewstack.io/javascript/) [Programming Languages](https://thenewstack.io/programming-languages/) [Python](https://thenewstack.io/python/) [Rust](https://thenewstack.io/rust/) [TypeScript](https://thenewstack.io/typescript/) [Open source USearch library jumpstarts ScyllaDB vector search](https://thenewstack.io/open-source-usearch-library-jumpstarts-scylladb-vector-search/) Feb 5th 2026 12:00pm, by Jelani Harper [AWS WAF vs. Google Cloud Armor: A Multicloud Security Showdown](https://thenewstack.io/aws-waf-vs-google-cloud-armor-a-multicloud-security-showdown/) Nov 25th 2025 10:00am, by Advait Patel [Goodbye Dashboards: Agents Deliver Answers, Not Just Reports](https://thenewstack.io/goodbye-dashboards-agents-deliver-answers-not-just-reports/) Nov 23rd 2025 9:00am, by Ketan Karkhanis [Rust vs. C++: a Modern Take on Performance and Safety](https://thenewstack.io/rust-vs-c-a-modern-take-on-performance-and-safety/) Oct 22nd 2025 2:00pm, by Zziwa Raymond Ian [Building a Real-Time System Monitor in Rust Terminal](https://thenewstack.io/building-a-real-time-system-monitor-in-rust-terminal/) Oct 15th 2025 7:05am, by Tinega Onchari [How to integrate VS Code with Ollama for local AI assistance](https://thenewstack.io/how-to-integrate-vs-code-with-ollama-for-local-ai-assistance/) Apr 1st 2026 8:00am, by Jack Wallen [JetBrains: AI agents are about to repeat the cloud ROI crisis](https://thenewstack.io/jetbrains-central-ai-agents/) Mar 31st 2026 4:02pm, by Darryl K. Taft [Claude Code users say they’re hitting usage limits faster than normal](https://thenewstack.io/claude-code-usage-limits/) Mar 31st 2026 2:30pm, by Meredith Shubel [OpenAI's Codex gets plugins](https://thenewstack.io/openais-codex-gets-plugins/) Mar 27th 2026 8:20am, by Frederic Lardinois [GitHub will train AI models on your Copilot data — and share it with Microsoft](https://thenewstack.io/github-copilot-interaction-data/) Mar 27th 2026 6:37am, by Meredith Shubel [Go Experts: 'I Don't Want to Maintain AI-Generated Code'](https://thenewstack.io/go-experts-i-dont-want-to-maintain-ai-generated-code/) Sep 28th 2025 6:00am, by David Cassel [How To Run Kubernetes Commands in Go: Steps and Best Practices](https://thenewstack.io/how-to-run-kubernetes-commands-in-go-steps-and-best-practices/) Jun 27th 2025 8:00am, by Sunny Yadav [Prepare Your Mac for Go Development](https://thenewstack.io/prepare-your-mac-for-go-development/) Apr 12th 2025 7:00am, by Damon M. Garn [Pagoda: A Web Development Starter Kit for Go Programmers](https://thenewstack.io/pagoda-a-web-development-starter-kit-for-go-programmers/) Mar 19th 2025 6:10am, by Loraine Lawson [Microsoft TypeScript Devs Explain Why They Chose Go Over Rust, C\#](https://thenewstack.io/microsoft-typescript-devs-explain-why-they-chose-go-over-rust-c/) Mar 18th 2025 7:00am, by David Cassel [Java 26 lands without an LTS badge. Here's why developers should care anyway.](https://thenewstack.io/java-26-performance-ai/) Mar 18th 2026 9:35am, by Darryl K. Taft [62% of enterprises now use Java to power AI apps](https://thenewstack.io/2026-java-ai-apps/) Feb 10th 2026 12:58pm, by Darryl K. Taft [BellSoft bets Java expertise can beat hardened container wave](https://thenewstack.io/bellsoft-bets-java-expertise-can-beat-hardened-container-wave/) Jan 26th 2026 3:00pm, by Darryl K. Taft [Java Developers Get Multiple Paths To Building AI Agents](https://thenewstack.io/java-developers-get-multiple-paths-to-building-ai-agents/) Dec 26th 2025 7:02am, by Darryl K. Taft [Your Enterprise AI Strategy Must Start With Java, Not Python](https://thenewstack.io/your-enterprise-ai-strategy-must-start-with-java-not-python/) Dec 22nd 2025 1:00pm, by Michael CotĂ© [TypeScript 6.0 RC arrives as a bridge to a faster future](https://thenewstack.io/typescript-6-0-rc-arrives-as-a-bridge-to-a-faster-future/) Mar 14th 2026 9:00am, by Darryl K. Taft [WebAssembly is everywhere. Here's how it works](https://thenewstack.io/webassembly-is-everywhere-heres-how-it-works/) Feb 25th 2026 11:00am, by Jessica Wachtel [Wasm vs. JavaScript: Who wins at a million rows?](https://thenewstack.io/wasm-vs-javascript-who-wins-at-a-million-rows/) Feb 22nd 2026 6:00am, by Jessica Wachtel [Arcjet reaches v1.0, promises stable security for JavaScript apps](https://thenewstack.io/arcjet-reaches-v1-0-promises-stable-security-for-javascript-apps/) Feb 14th 2026 7:00am, by Darryl K. Taft [How WebAssembly and Web Workers prevent UI freezes](https://thenewstack.io/how-webassembly-and-web-workers-prevent-ui-freezes/) Feb 7th 2026 9:00am, by Jessica Wachtel [Will AI force code to evolve or make it extinct?](https://thenewstack.io/ai-programming-languages-future/) Mar 22nd 2026 6:00am, by David Cassel [Java 26 lands without an LTS badge. Here's why developers should care anyway.](https://thenewstack.io/java-26-performance-ai/) Mar 18th 2026 9:35am, by Darryl K. Taft [TypeScript 6.0 RC arrives as a bridge to a faster future](https://thenewstack.io/typescript-6-0-rc-arrives-as-a-bridge-to-a-faster-future/) Mar 14th 2026 9:00am, by Darryl K. Taft [Nearly half of all companies now use Rust in production, survey finds](https://thenewstack.io/rust-enterprise-developers/) Mar 6th 2026 10:45am, by Darryl K. Taft [Statistical language R is making a comeback against Python](https://thenewstack.io/statistical-language-r-is-making-a-comeback-against-python/) Feb 12th 2026 2:57pm, by Darryl K. Taft [OpenAI acquires Astral to bring open source Python developer tools to Codex — but details are still fuzzy](https://thenewstack.io/openai-astral-acquisition/) Mar 20th 2026 7:33am, by Meredith Shubel [Python virtual environments: isolation without the chaos](https://thenewstack.io/python-virtual-environments-isolation-without-the-chaos/) Feb 16th 2026 7:00am, by Jessica Wachtel [Statistical language R is making a comeback against Python](https://thenewstack.io/statistical-language-r-is-making-a-comeback-against-python/) Feb 12th 2026 2:57pm, by Darryl K. Taft [Arcjet's Python SDK Embeds Security in Code](https://thenewstack.io/arcjets-python-sdk-embeds-security-in-code/) Jan 16th 2026 2:00pm, by Darryl K. Taft [2025: The Year of the Return of the Ada Programming Language?](https://thenewstack.io/2025-the-year-of-the-return-of-the-ada-programming-language/) Jan 14th 2026 4:00pm, by Darryl K. Taft [Nearly half of all companies now use Rust in production, survey finds](https://thenewstack.io/rust-enterprise-developers/) Mar 6th 2026 10:45am, by Darryl K. Taft [Wasm vs. JavaScript: Who wins at a million rows?](https://thenewstack.io/wasm-vs-javascript-who-wins-at-a-million-rows/) Feb 22nd 2026 6:00am, by Jessica Wachtel [Open source USearch library jumpstarts ScyllaDB vector search](https://thenewstack.io/open-source-usearch-library-jumpstarts-scylladb-vector-search/) Feb 5th 2026 12:00pm, by Jelani Harper [The 'weird' things that happened when Clickhouse replaced C++ with Rust](https://thenewstack.io/the-weird-things-that-happened-when-clickhouse-replaced-c-with-rust/) Feb 4th 2026 7:26am, by B. Cameron Gain [Async Rust: Pinning demystified](https://thenewstack.io/async-rust-pinning-demystified/) Jan 26th 2026 11:00am, by Anshul Gupta [TypeScript 6.0 RC arrives as a bridge to a faster future](https://thenewstack.io/typescript-6-0-rc-arrives-as-a-bridge-to-a-faster-future/) Mar 14th 2026 9:00am, by Darryl K. Taft [Mastra empowers web devs to build AI agents in TypeScript](https://thenewstack.io/mastra-empowers-web-devs-to-build-ai-agents-in-typescript/) Jan 28th 2026 11:00am, by Loraine Lawson [Inferno Vet Creates Frontend Framework Built With AI in Mind](https://thenewstack.io/inferno-vet-creates-frontend-framework-built-with-ai-in-mind/) Dec 10th 2025 11:00am, by Loraine Lawson [JavaScript Utility Library Lodash Changing Governance Model](https://thenewstack.io/javascript-utility-library-lodash-changing-governance-model/) Nov 1st 2025 7:00am, by Loraine Lawson [Microsoft TypeScript Devs Explain Why They Chose Go Over Rust, C\#](https://thenewstack.io/microsoft-typescript-devs-explain-why-they-chose-go-over-rust-c/) Mar 18th 2025 7:00am, by David Cassel 2025-06-16 13:00:29 Python ThreadPool vs. Multiprocessing​ tutorial, [Programming Languages](https://thenewstack.io/category/programming-languages/) / [Python](https://thenewstack.io/category/python/) / [Software Development](https://thenewstack.io/category/software-development/) # Python ThreadPool vs. Multiprocessing​ Learn the differences between concurrency, parallelism and async tasks in Python, and when to use ThreadPoolExecutor vs. ProcessPoolExecutor. Jun 16th, 2025 1:00pm by [Jessica Wachtel](https://thenewstack.io/author/jessica-wachtel/ "Posts by Jessica Wachtel") ![Featued image for: Python ThreadPool vs. Multiprocessing​](https://cdn.thenewstack.io/media/2025/04/50c2b944-python-1024x683.png) Before we dive into [multithreading](https://thenewstack.io/pythons-gil-multithreading-and-multiprocessing/) and [multiprocessing](https://thenewstack.io/pythons-gil-multithreading-and-multiprocessing/), let’s first cover some background info on [concurrency](https://thenewstack.io/golang-1-22-redefines-the-for-loop-for-easier-concurrency/), [parallelism](https://thenewstack.io/python-to-drop-the-global-lock-for-greater-parallelism/) and [asynchronous tasks](https://thenewstack.io/3-types-of-asynchronous-programming/). These three concepts are related but distinct. Let’s use a simple example to understand them: a mechanics shop. Concurrency happens when one mechanic works on several cars by switching between them. For example, the mechanic changes the oil in one car while waiting for a part for another. They don’t finish one car before starting the next, but they can’t do two tasks at exactly the same time. The tasks overlap in time but don’t happen simultaneously. Parallelism occurs when several mechanics work on different cars at the same time. One mechanic changes the oil, another replaces the brakes and another installs a battery. These tasks happen simultaneously, and can be completed at different times or at the same time because different people handle them. Asynchronous tasks work like this: You drop your car off and get a text when it is done. While the work takes place, you can do whatever you want: Go to work, the beach or do anything else, and the work still gets done in the background. Now to the tech explanations. The quick answer: Async tasks use concurrency, but not all concurrency is async. Parallelism stands apart and mainly relates to CPU usage. All parallelism involves concurrency, but not all concurrency achieves parallelism. Confusing? Let’s keep going\! The long answer: Asynchronous tasks form a type of concurrency, usually for I/O-bound work. Tasks yield control while waiting, for example, for a file or network response. This allows other tasks to run. Concurrency covers running multiple tasks during the same period using threads, coroutines (async/await) or other methods. Parallelism means actually doing tasks simultaneously on multiple CPU cores. This approach fits CPU-bound work and often uses multiprocessing. TRENDING STORIES Why does this matter to [Python](https://thenewstack.io/python/) programmers? ## Multiprocessing and Multithreading: Definitions and Uses Multithreading (concurrency) lets a single program create multiple threads sharing the same memory space. These threads run concurrently, switching between tasks to make progress. Multithreading works well for I/O-bound tasks. However, because of Python’s [Global Interpreter Lock (GIL)](https://thenewstack.io/circumventing-pythons-gil-with-asyncio/), threads cannot run Python bytecode in true parallel on multiple CPU cores. Multiprocessing (parallelism) runs multiple processes independently. Each process has its own memory space and Python interpreter. This setup enables true parallelism by running tasks simultaneously on multiple CPU cores. Multiprocessing suits CPU-bound tasks because it bypasses the GIL limitation. Deciding between thread pools and process pools depends on your task type — whether it’s I/O-bound or CPU-bound. ### Why Do We Need Multithreading and Multiprocessing? Meet Python’s GIL The GIL is a mechanism in [CPython](https://thenewstack.io/guido-van-rossums-ambitious-plans-for-improving-python-performance/), the standard Python implementation. It allows only one thread to execute Python bytecode at a time, even on multicore processors. Python introduced the GIL to simplify memory management and ensure thread safety. Because the GIL limits thread execution to one thread at a time: - Threads cannot run Python bytecode in parallel, which reduces their effectiveness for CPU-bound tasks that require constant computation. This means: - When you use multithreading, I/O-bound tasks can run efficiently because threads spend most of their time waiting on external resources like files, databases or network responses. The GIL only blocks actual Python bytecode execution. - Multiprocessing enables true parallelism because each process has its own Python interpreter and GIL. This setup lets CPU-intensive tasks run across multiple cores. The GIL is why you use multithreading and multiprocessing to improve performance and responsiveness in Python applications when multiple tasks must execute at the same time. ### Syntax Python offers several ways to handle concurrency and parallelism. Two of the most common are \`ThreadPoolExecutor\` and \`ProcessPoolExecutor\`. Both provide powerful abstractions that simplify complex concurrency management. These tools come from the \`concurrent.futures\` module. They help you manage async tasks efficiently. \`ThreadPoolExecutor\` and \`ProcessPoolExecutor\` share the same interface. This similarity makes switching between them easy with minimal code changes. Using the \`with\` statement ensures threads or processes clean up properly when you finish. | | | |---|---| | | from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor | | | \# threading | | | with ThreadPoolExecutor(max\_workers=4) as executor: | | | results = executor.map(some\_function, iterable) | | | \# multiprocessing | | | with ProcessPoolExecutor(max\_workers=4) as executor: | | | results = executor.map(some\_function, iterable) | [view raw](https://gist.github.com/JessicaWachtel/fa85026e33c3efc9194afe8852995125/raw/e8b9ca2877d967641e05d45179e735abb04d6581/gistfile1.txt) [gistfile1.txt](https://gist.github.com/JessicaWachtel/fa85026e33c3efc9194afe8852995125#file-gistfile1-txt) hosted with ❀ by [GitHub](https://github.com/) ## What Is Python’s ThreadPool? ### Definition and How It Works \`ThreadPoolExecutor\` acts like the mechanic quickly switching between multiple cars on a task-by-task basis. \`ThreadPoolExecutor\` executes tasks concurrently using threads within the same Python process. Because threads share memory, they create and switch quickly. ### When To Use \`ThreadPoolExecutor\` Use a thread pool when your application spends a lot of time on tasks that don’t need much CPU. Tasks that involve waiting suit thread pools best since threads can run while others wait. Examples include: - HTTP requests - Reading and writing to disk - Database queries - When you need to wait for user input ### Example: Using ThreadPoolExecutor for I/O-bound Tasks This example simulates fetching data from multiple URLs concurrently. Each \`fetch\_data\` call waits for 2 seconds, but threads make the overall time much shorter than running sequentially. | | | |---|---| | | import time | | | from concurrent.futures import ThreadPoolExecutor | | | def fetch\_data(url): | | | print(f"Fetching from {url}") | | | time.sleep(2) \# Simulate delay | | | return f"Data from {url}" | | | urls = \['http://example.com/a', 'http://example.com/b', 'http://example.com/c'\] | | | with ThreadPoolExecutor(max\_workers=3) as executor: | | | results = executor.map(fetch\_data, urls) | | | for result in results: | | | print(result) | [view raw](https://gist.github.com/JessicaWachtel/d424d8c7eec2c1e6b28f75f1a5d60ce7/raw/3c9bba2c2a211ca5646f87b5451f0fd46de9286b/gistfile1.txt) [gistfile1.txt](https://gist.github.com/JessicaWachtel/d424d8c7eec2c1e6b28f75f1a5d60ce7#file-gistfile1-txt) hosted with ❀ by [GitHub](https://github.com/) View the code on [Gist](https://gist.github.com/JessicaWachtel/d424d8c7eec2c1e6b28f75f1a5d60ce7). ## What Is Python Multiprocessing? ### Definition and How It Works ProcessPoolExecutor (multiprocessing) acts like having multiple mechanics, each working on their own car at the same time. Multiprocessing runs tasks in separate processes, each with its own memory space and Python interpreter. This allows true parallel execution on multiple CPU cores. Unlike threads, multiple mechanics work simultaneously without waiting. ### When To Use Multiprocessing Multiprocessing excels at tasks that you can spread across multiple cores. Use a process pool for tasks that consume a lot of CPU. These tasks might: - Perform mathematical computations - Process large datasets - Process images and videos ### Example: Using ProcessPoolExecutor for CPU-Bound Tasks In the example below, each factorial calculation requires heavy CPU work. Running them in separate processes lets Python bypass the GIL and use multiple cores. | | | |---|---| | | import time | | | from concurrent.futures import ProcessPoolExecutor | | | def compute\_factorial(n): | | | if n == 0: | | | return 1 | | | else: | | | return n \* compute\_factorial(n - 1) | | | numbers = \[20, 21, 22, 23\] | | | with ProcessPoolExecutor(max\_workers=4) as executor: | | | results = executor.map(compute\_factorial, numbers) | | | for result in results: | | | print(result) | [view raw](https://gist.github.com/JessicaWachtel/fb9ed1a446b436e19eff83208208484b/raw/6721f9c2e3d6859ca80b7a4f83e54e12a11f028c/gistfile1.txt) [gistfile1.txt](https://gist.github.com/JessicaWachtel/fb9ed1a446b436e19eff83208208484b#file-gistfile1-txt) hosted with ❀ by [GitHub](https://github.com/) View the code on [Gist](https://gist.github.com/JessicaWachtel/fb9ed1a446b436e19eff83208208484b). ## Key Differences Between ThreadPool and Multiprocessing Let’s evaluate thread pools and multiprocessing based on important criteria to help you choose the right approach. - **Parallelism:** Threads offer concurrency but not true parallelism due to the GIL. Processes provide real parallel execution. - **Memory sharing:** Threads share data easily. Processes cannot share memory directly. - **Startup time:** Threads start faster. Processes take longer due to the overhead of creating a new interpreter. - **Best use cases:** Threads fit I/O-bound tasks like downloading files or accessing APIs. Processes fit CPU-bound tasks like number crunching or data transformation. ### When To Use \`ThreadPoolExecutor\` vs. \`ProcessPoolExecutor\` Choose \`ThreadPoolExecutor\` when: - Your tasks involve a lot of waiting. - You need lightweight concurrency. - Memory sharing matters. Choose \`ProcessPoolExecutor\` when: - Tasks require heavy CPU work. - You want to use multiple CPU cores. - You do not need to share memory between tasks. ## Performance Considerations and Benchmarks ### Measuring Execution Time for I/O-Bound Tasks In this example, we simulate I/O-bound tasks by sleeping for a few seconds. Using \`ThreadPoolExecutor\`, each task runs in its own thread. Threads overlap while waiting, so the overall runtime is much shorter than running tasks one after the other. This shows how threading improves performance for I/O-bound workloads. | | | |---|---| | | import time | | | from concurrent.futures import ThreadPoolExecutor | | | start = time.time() | | | def io\_task(n): | | | time.sleep(n) | | | return n | | | with ThreadPoolExecutor() as executor: | | | executor.map(io\_task, \[1, 2, 3, 4\]) | | | print("Total time (threads for I/O):", time.time() - start) | [view raw](https://gist.github.com/JessicaWachtel/06e2237ba600b2ab6cbdc32088885651/raw/117229bfddc2d2ce2a27eb573c20300554c78c95/gistfile1.txt) [gistfile1.txt](https://gist.github.com/JessicaWachtel/06e2237ba600b2ab6cbdc32088885651#file-gistfile1-txt) hosted with ❀ by [GitHub](https://github.com/) The output will be the amount of time it takes for your system to complete this task. ### Measuring Execution Time for CPU-Bound Tasks Here, the function performs heavy arithmetic to simulate a CPU-bound task. These operations benefit from true parallelism. Using \`ProcessPoolExecutor\`, each task runs in a separate process on its own core if available. Processes bypass Python’s GIL, so they can execute Python bytecode in parallel. This reduces total runtime and improves efficiency for CPU-heavy workloads. | | | |---|---| | | import time | | | from concurrent.futures import ProcessPoolExecutor | | | start = time.time() | | | def cpu\_task(n): | | | total = 0 | | | for i in range(10\*\*6): | | | total += i \* n | | | return total | | | with ProcessPoolExecutor() as executor: | | | executor.map(cpu\_task, \[1, 2, 3, 4\]) | | | print("Total time (processes for CPU):", time.time() - start) | [view raw](https://gist.github.com/JessicaWachtel/bf7211d1e2b797fe899693fc6217b660/raw/78c5dc1dcd4e1c69ec4f4dd90152b42522c3f8cc/gistfile1.txt) [gistfile1.txt](https://gist.github.com/JessicaWachtel/bf7211d1e2b797fe899693fc6217b660#file-gistfile1-txt) hosted with ❀ by [GitHub](https://github.com/) The output will be the amount of time it takes for your system to complete this task. ## Common Pitfalls and Best Practices ### Avoiding Deadlocks in \`ThreadPool\` A deadlock happens when two or more threads wait for each other to release resources, causing all to stop progressing. Think of two mechanics holding tools that the other needs and refusing to let go. Work comes to a halt. You can avoid deadlocks by: - Never blocking a thread indefinitely or waiting for it to complete - Using the \`with\` context to ensure threads join automatically - Being cautious with shared resources and protecting them with locks if needed ### Handling Memory Overhead in Multiprocessing Each process has its own memory space, so data does not share directly between processes. This separation increases memory overhead because large data structures duplicate across processes and consume more system memory. To manage memory: - Avoid passing large data structures between processes when possible. - Use tools like \`multiprocessing.Manager\` or shared memory constructs if you must share data to reduce duplication and memory use. ### Debugging ThreadPool and Multiprocessing Issues Debugging concurrency and parallelism poses challenges because threads and processes run independently and often at the same time. Issues like race conditions or hidden errors become harder to detect. Here are some tips: - Thread issues, such as race conditions, can prove tricky to reproduce and fix. Use synchronization tools like \`threading.Lock()\` to control access to shared resources. - Process issues might not show standard tracebacks in the main program. Use \`multiprocessing.get\_logger()\` or add logging inside subprocesses to capture errors. - For complex debugging and performance analysis, use profiling tools or higher-level frameworks like \`joblib\` or \`dask\` that offer better abstractions and diagnostics. ## Conclusion Understanding the differences between concurrency, parallelism and asynchronous tasks helps you determine which approach your task requires. In Python, \`ThreadPoolExecutor\` and \`ProcessPoolExecutor\` give you simple ways to handle threading and multiprocessing for I/O-bound and CPU-bound tasks efficiently. Knowing when to use each can save time, reduce complexity and improve performance. Created with Sketch. [![](https://thenewstack.io/wp-content/uploads/2023/04/d55571c0-cropped-b09ca100-image1-600x600.jpg) Jessica Wachtel is a developer marketing writer at InfluxData where she creates content that helps make the world of time series data more understandable and accessible. Jessica has a background in software development and technical journalism. Read more from Jessica Wachtel](https://thenewstack.io/author/jessica-wachtel/) SHARE THIS STORY TRENDING STORIES SHARE THIS STORY TRENDING STORIES TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day. SUBSCRIBE The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our [Terms of Use](https://thenewstack.io/terms-of-use/) and [Privacy Policy](https://thenewstack.io/privacy-policy/). ARCHITECTURE [Cloud Native Ecosystem](https://thenewstack.io/cloud-native/) [Containers](https://thenewstack.io/containers/) [Databases](https://thenewstack.io/databases/) [Edge Computing](https://thenewstack.io/edge-computing/) [Infrastructure as Code](https://thenewstack.io/infrastructure-as-code/) [Linux](https://thenewstack.io/linux/) [Microservices](https://thenewstack.io/microservices/) [Open Source](https://thenewstack.io/open-source/) [Networking](https://thenewstack.io/networking/) [Storage](https://thenewstack.io/storage/) ENGINEERING [AI](https://thenewstack.io/ai/) [AI Engineering](https://thenewstack.io/ai-engineering/) [API Management](https://thenewstack.io/api-management/) [Backend development](https://thenewstack.io/backend-development/) [Data](https://thenewstack.io/data/) [Frontend Development](https://thenewstack.io/frontend-development/) [Large Language Models](https://thenewstack.io/llm/) [Security](https://thenewstack.io/security/) [Software Development](https://thenewstack.io/software-development/) [WebAssembly](https://thenewstack.io/webassembly/) OPERATIONS [AI Operations](https://thenewstack.io/ai-operations/) [CI/CD](https://thenewstack.io/ci-cd/) [Cloud Services](https://thenewstack.io/cloud-services/) [DevOps](https://thenewstack.io/devops/) [Kubernetes](https://thenewstack.io/kubernetes/) [Observability](https://thenewstack.io/observability/) [Operations](https://thenewstack.io/operations/) [Platform Engineering](https://thenewstack.io/platform-engineering/) CHANNELS [Podcasts](https://thenewstack.io/podcasts/) [Ebooks](https://thenewstack.io/ebooks/) [Events](https://thenewstack.io/events/) [Webinars](https://thenewstack.io/webinars/) [Newsletter](https://thenewstack.io/newsletter/) [TNS RSS Feeds](https://thenewstack.io/rss-feeds/) THE NEW STACK [About / Contact](https://thenewstack.io/about-and-contact-info/) [Sponsors](https://thenewstack.io/sponsors/) [Advertise With Us](https://thenewstack.io/sponsorship/) [Contributions](https://thenewstack.io/contributions/) [roadmap.sh Community created roadmaps, articles, resources and journeys for developers to help you choose your path and grow in your career.](https://roadmap.sh/?utm_source=The+New+Stack&utm_medium=Referral&utm_campaign=Footer) [Frontend Developer Roadmap](https://roadmap.sh/frontend?utm_source=The+New+Stack&utm_medium=Referral&utm_campaign=Footer) [Backend Developer Roadmap](https://roadmap.sh/backend?utm_source=The+New+Stack&utm_medium=Referral&utm_campaign=Footer) [Devops Roadmap](https://roadmap.sh/devops?utm_source=The+New+Stack&utm_medium=Referral&utm_campaign=Footer) © The New Stack 2026 [Disclosures](https://thenewstack.io/disclosure-guidelines/) [Terms of Use](https://thenewstack.io/terms-of-use/) [Advertising Terms & Conditions](https://thenewstack.io/advertising-terms-conditions/) [Privacy Policy](https://thenewstack.io/privacy-policy/) [Cookie Policy](https://thenewstack.io/cookie-policy/) FOLLOW TNS ![](https://www.facebook.com/tr?id=1244424359562950&ev=PageView&noscript=1) ![](https://px.ads.linkedin.com/collect/?pid=4664394&fmt=gif)
Readable Markdown
Before we dive into [multithreading](https://thenewstack.io/pythons-gil-multithreading-and-multiprocessing/) and [multiprocessing](https://thenewstack.io/pythons-gil-multithreading-and-multiprocessing/), let’s first cover some background info on [concurrency](https://thenewstack.io/golang-1-22-redefines-the-for-loop-for-easier-concurrency/), [parallelism](https://thenewstack.io/python-to-drop-the-global-lock-for-greater-parallelism/) and [asynchronous tasks](https://thenewstack.io/3-types-of-asynchronous-programming/). These three concepts are related but distinct. Let’s use a simple example to understand them: a mechanics shop. Concurrency happens when one mechanic works on several cars by switching between them. For example, the mechanic changes the oil in one car while waiting for a part for another. They don’t finish one car before starting the next, but they can’t do two tasks at exactly the same time. The tasks overlap in time but don’t happen simultaneously. Parallelism occurs when several mechanics work on different cars at the same time. One mechanic changes the oil, another replaces the brakes and another installs a battery. These tasks happen simultaneously, and can be completed at different times or at the same time because different people handle them. Asynchronous tasks work like this: You drop your car off and get a text when it is done. While the work takes place, you can do whatever you want: Go to work, the beach or do anything else, and the work still gets done in the background. Now to the tech explanations. The quick answer: Async tasks use concurrency, but not all concurrency is async. Parallelism stands apart and mainly relates to CPU usage. All parallelism involves concurrency, but not all concurrency achieves parallelism. Confusing? Let’s keep going\! The long answer: Asynchronous tasks form a type of concurrency, usually for I/O-bound work. Tasks yield control while waiting, for example, for a file or network response. This allows other tasks to run. Concurrency covers running multiple tasks during the same period using threads, coroutines (async/await) or other methods. Parallelism means actually doing tasks simultaneously on multiple CPU cores. This approach fits CPU-bound work and often uses multiprocessing. TRENDING STORIES Why does this matter to [Python](https://thenewstack.io/python/) programmers? ## Multiprocessing and Multithreading: Definitions and Uses Multithreading (concurrency) lets a single program create multiple threads sharing the same memory space. These threads run concurrently, switching between tasks to make progress. Multithreading works well for I/O-bound tasks. However, because of Python’s [Global Interpreter Lock (GIL)](https://thenewstack.io/circumventing-pythons-gil-with-asyncio/), threads cannot run Python bytecode in true parallel on multiple CPU cores. Multiprocessing (parallelism) runs multiple processes independently. Each process has its own memory space and Python interpreter. This setup enables true parallelism by running tasks simultaneously on multiple CPU cores. Multiprocessing suits CPU-bound tasks because it bypasses the GIL limitation. Deciding between thread pools and process pools depends on your task type — whether it’s I/O-bound or CPU-bound. ### Why Do We Need Multithreading and Multiprocessing? Meet Python’s GIL The GIL is a mechanism in [CPython](https://thenewstack.io/guido-van-rossums-ambitious-plans-for-improving-python-performance/), the standard Python implementation. It allows only one thread to execute Python bytecode at a time, even on multicore processors. Python introduced the GIL to simplify memory management and ensure thread safety. Because the GIL limits thread execution to one thread at a time: - Threads cannot run Python bytecode in parallel, which reduces their effectiveness for CPU-bound tasks that require constant computation. This means: - When you use multithreading, I/O-bound tasks can run efficiently because threads spend most of their time waiting on external resources like files, databases or network responses. The GIL only blocks actual Python bytecode execution. - Multiprocessing enables true parallelism because each process has its own Python interpreter and GIL. This setup lets CPU-intensive tasks run across multiple cores. The GIL is why you use multithreading and multiprocessing to improve performance and responsiveness in Python applications when multiple tasks must execute at the same time. ### Syntax Python offers several ways to handle concurrency and parallelism. Two of the most common are \`ThreadPoolExecutor\` and \`ProcessPoolExecutor\`. Both provide powerful abstractions that simplify complex concurrency management. These tools come from the \`concurrent.futures\` module. They help you manage async tasks efficiently. \`ThreadPoolExecutor\` and \`ProcessPoolExecutor\` share the same interface. This similarity makes switching between them easy with minimal code changes. Using the \`with\` statement ensures threads or processes clean up properly when you finish. | | | |---|---| | | from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor | | | \# threading | | | with ThreadPoolExecutor(max\_workers=4) as executor: | | | results = executor.map(some\_function, iterable) | | | \# multiprocessing | | | with ProcessPoolExecutor(max\_workers=4) as executor: | | | results = executor.map(some\_function, iterable) | ## What Is Python’s ThreadPool? ### Definition and How It Works \`ThreadPoolExecutor\` acts like the mechanic quickly switching between multiple cars on a task-by-task basis. \`ThreadPoolExecutor\` executes tasks concurrently using threads within the same Python process. Because threads share memory, they create and switch quickly. ### When To Use \`ThreadPoolExecutor\` Use a thread pool when your application spends a lot of time on tasks that don’t need much CPU. Tasks that involve waiting suit thread pools best since threads can run while others wait. Examples include: - HTTP requests - Reading and writing to disk - Database queries - When you need to wait for user input ### Example: Using ThreadPoolExecutor for I/O-bound Tasks This example simulates fetching data from multiple URLs concurrently. Each \`fetch\_data\` call waits for 2 seconds, but threads make the overall time much shorter than running sequentially. | | | |---|---| | | import time | | | from concurrent.futures import ThreadPoolExecutor | | | def fetch\_data(url): | | | print(f"Fetching from {url}") | | | time.sleep(2) \# Simulate delay | | | return f"Data from {url}" | | | urls = \['http://example.com/a', 'http://example.com/b', 'http://example.com/c'\] | | | with ThreadPoolExecutor(max\_workers=3) as executor: | | | results = executor.map(fetch\_data, urls) | | | for result in results: | | | print(result) | ## What Is Python Multiprocessing? ### Definition and How It Works ProcessPoolExecutor (multiprocessing) acts like having multiple mechanics, each working on their own car at the same time. Multiprocessing runs tasks in separate processes, each with its own memory space and Python interpreter. This allows true parallel execution on multiple CPU cores. Unlike threads, multiple mechanics work simultaneously without waiting. ### When To Use Multiprocessing Multiprocessing excels at tasks that you can spread across multiple cores. Use a process pool for tasks that consume a lot of CPU. These tasks might: - Perform mathematical computations - Process large datasets - Process images and videos ### Example: Using ProcessPoolExecutor for CPU-Bound Tasks In the example below, each factorial calculation requires heavy CPU work. Running them in separate processes lets Python bypass the GIL and use multiple cores. | | | |---|---| | | import time | | | from concurrent.futures import ProcessPoolExecutor | | | def compute\_factorial(n): | | | if n == 0: | | | return 1 | | | else: | | | return n \* compute\_factorial(n - 1) | | | numbers = \[20, 21, 22, 23\] | | | with ProcessPoolExecutor(max\_workers=4) as executor: | | | results = executor.map(compute\_factorial, numbers) | | | for result in results: | | | print(result) | ## Key Differences Between ThreadPool and Multiprocessing Let’s evaluate thread pools and multiprocessing based on important criteria to help you choose the right approach. - **Parallelism:** Threads offer concurrency but not true parallelism due to the GIL. Processes provide real parallel execution. - **Memory sharing:** Threads share data easily. Processes cannot share memory directly. - **Startup time:** Threads start faster. Processes take longer due to the overhead of creating a new interpreter. - **Best use cases:** Threads fit I/O-bound tasks like downloading files or accessing APIs. Processes fit CPU-bound tasks like number crunching or data transformation. ### When To Use \`ThreadPoolExecutor\` vs. \`ProcessPoolExecutor\` Choose \`ThreadPoolExecutor\` when: - Your tasks involve a lot of waiting. - You need lightweight concurrency. - Memory sharing matters. Choose \`ProcessPoolExecutor\` when: - Tasks require heavy CPU work. - You want to use multiple CPU cores. - You do not need to share memory between tasks. ## Performance Considerations and Benchmarks ### Measuring Execution Time for I/O-Bound Tasks In this example, we simulate I/O-bound tasks by sleeping for a few seconds. Using \`ThreadPoolExecutor\`, each task runs in its own thread. Threads overlap while waiting, so the overall runtime is much shorter than running tasks one after the other. This shows how threading improves performance for I/O-bound workloads. | | | |---|---| | | import time | | | from concurrent.futures import ThreadPoolExecutor | | | start = time.time() | | | def io\_task(n): | | | time.sleep(n) | | | return n | | | with ThreadPoolExecutor() as executor: | | | executor.map(io\_task, \[1, 2, 3, 4\]) | | | print("Total time (threads for I/O):", time.time() - start) | The output will be the amount of time it takes for your system to complete this task. ### Measuring Execution Time for CPU-Bound Tasks Here, the function performs heavy arithmetic to simulate a CPU-bound task. These operations benefit from true parallelism. Using \`ProcessPoolExecutor\`, each task runs in a separate process on its own core if available. Processes bypass Python’s GIL, so they can execute Python bytecode in parallel. This reduces total runtime and improves efficiency for CPU-heavy workloads. | | | |---|---| | | import time | | | from concurrent.futures import ProcessPoolExecutor | | | start = time.time() | | | def cpu\_task(n): | | | total = 0 | | | for i in range(10\*\*6): | | | total += i \* n | | | return total | | | with ProcessPoolExecutor() as executor: | | | executor.map(cpu\_task, \[1, 2, 3, 4\]) | | | print("Total time (processes for CPU):", time.time() - start) | The output will be the amount of time it takes for your system to complete this task. ## Common Pitfalls and Best Practices ### Avoiding Deadlocks in \`ThreadPool\` A deadlock happens when two or more threads wait for each other to release resources, causing all to stop progressing. Think of two mechanics holding tools that the other needs and refusing to let go. Work comes to a halt. You can avoid deadlocks by: - Never blocking a thread indefinitely or waiting for it to complete - Using the \`with\` context to ensure threads join automatically - Being cautious with shared resources and protecting them with locks if needed ### Handling Memory Overhead in Multiprocessing Each process has its own memory space, so data does not share directly between processes. This separation increases memory overhead because large data structures duplicate across processes and consume more system memory. To manage memory: - Avoid passing large data structures between processes when possible. - Use tools like \`multiprocessing.Manager\` or shared memory constructs if you must share data to reduce duplication and memory use. ### Debugging ThreadPool and Multiprocessing Issues Debugging concurrency and parallelism poses challenges because threads and processes run independently and often at the same time. Issues like race conditions or hidden errors become harder to detect. Here are some tips: - Thread issues, such as race conditions, can prove tricky to reproduce and fix. Use synchronization tools like \`threading.Lock()\` to control access to shared resources. - Process issues might not show standard tracebacks in the main program. Use \`multiprocessing.get\_logger()\` or add logging inside subprocesses to capture errors. - For complex debugging and performance analysis, use profiling tools or higher-level frameworks like \`joblib\` or \`dask\` that offer better abstractions and diagnostics. ## Conclusion Understanding the differences between concurrency, parallelism and asynchronous tasks helps you determine which approach your task requires. In Python, \`ThreadPoolExecutor\` and \`ProcessPoolExecutor\` give you simple ways to handle threading and multiprocessing for I/O-bound and CPU-bound tasks efficiently. Knowing when to use each can save time, reduce complexity and improve performance. Created with Sketch.
Shard197 (laksa)
Root Hash5306194916123425997
Unparsed URLio,thenewstack!/python-threadpool-vs-multiprocessing/ s443