{"id":283,"date":"2026-03-25T14:26:32","date_gmt":"2026-03-25T14:26:32","guid":{"rendered":"https:\/\/reservecli.dev\/?page_id=283"},"modified":"2026-03-25T22:26:37","modified_gmt":"2026-03-25T22:26:37","slug":"concurrency","status":"publish","type":"page","link":"https:\/\/reservecli.dev\/documentation\/concurrency\/","title":{"rendered":"concurrency"},"content":{"rendered":"\n<p>RESERVE achieves efficient batch data retrieval through controlled concurrency.<\/p>\n\n\n\n<p>RESERVE uses concurrency to improve performance when working with multiple FRED\u00ae series. Rather than fetching data one request at a time, RESERVE allows multiple network requests to be in flight simultaneously\u2014reducing total execution time for batch operations.<\/p>\n\n\n\n<p>Concurrency is intentionally scoped to <strong>network-bound workloads<\/strong>, where latency\u2014not CPU\u2014is the primary bottleneck.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How Concurrency Works<\/strong><\/h2>\n\n\n\n<p>Concurrency in RESERVE is controlled via a config.json setting or a global flag:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># Global flag example\n--concurrency int   max parallel requests for batch operations (default: 8)\n\n# Configuration in config.json\n{\n  \"api_key\": \"5fc037###################\",\n  \"default_format\": \"table\",\n  \"timeout\": \"30s\",\n  \"concurrency\": 8,\n  \"rate\": 5,\n  \"base_url\": \"https:\/\/api.stlouisfed.org\/fred\/\",\n  \"db_path\": \"\"\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># Global flag example<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">--concurrency<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">int<\/span><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #A3BE8C\">max<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">parallel<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">requests<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">for<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">batch<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">operations<\/span><span style=\"color: #D8DEE9FF\"> (default: <\/span><span style=\"color: #B48EAD\">8<\/span><span style=\"color: #D8DEE9FF\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># Configuration in config.json<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;api_key&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">5fc037###################<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;default_format&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">table<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;timeout&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">30s<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;concurrency&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">8<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;rate&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">5<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;base_url&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">https:\/\/api.stlouisfed.org\/fred\/<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;db_path&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>If not specified, RESERVE defaults to <strong>8 concurrent requests<\/strong>.<\/p>\n\n\n\n<p>When multiple series are requested, RESERVE:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>launches one goroutine per series<\/li>\n\n\n\n<li>limits active work using a bounded semaphore<\/li>\n\n\n\n<li>waits for all operations to complete<\/li>\n\n\n\n<li>preserves output in the original input order<\/li>\n<\/ul>\n\n\n\n<p>This ensures that concurrency improves performance without introducing unpredictability.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Where Concurrency Is Used<\/strong><\/h2>\n\n\n\n<p>Concurrency is applied in <strong>batch data retrieval workflows<\/strong>, including:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Series Metadata<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>reserve meta series GDP CPIAUCSL UNRATE<\/li>\n\n\n\n<li>reserve fetch series GDP CPIAUCSL &#8211;with-meta<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Observations (Time Series Data)<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>reserve obs get GDP CPIAUCSL UNRATE<\/li>\n\n\n\n<li>reserve fetch series GDP CPIAUCSL &#8211;with-obs<\/li>\n\n\n\n<li>reserve fetch query &#8220;inflation&#8221; &#8211;with-obs<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># FRED API does not return a combined payload.  The below uses concurrencty to make the SERIES request AND make the OBS request and stitch them together in a single JSON payload.\n\nreserve fetch series GDP --with-obs\n\n{\n  \"series_id\": \"GDP\",\n  \"title\": \"Gross Domestic Product\",\n  \"frequency\": \"Quarterly\",\n  \"units\": \"Billions of Dollars\",\n  \"observations\": &#91;\n    {\"date\": \"2023-01-01\", \"value\": 26813.6},\n    {\"date\": \"2023-04-01\", \"value\": 27063.0},\n    {\"date\": \"2023-07-01\", \"value\": 27357.8}\n  &#93;\n}\n\n# A reqeuest like this clearly bennefits from concurrent reqeuests and background data merging.\nreserve fetch series GDP CPIAUCSL UNRATE FEDFUNDS PCE --with-obs --concurrency 8<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># FRED API does not return a combined payload.  The below uses concurrencty to make the SERIES request AND make the OBS request and stitch them together in a single JSON payload.<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">reserve<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">fetch<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">series<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">GDP<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">--with-obs<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;series_id&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">GDP<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;title&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Gross Domestic Product<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;frequency&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Quarterly<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;units&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Billions of Dollars<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;observations&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> &#91;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">{<\/span><span style=\"color: #88C0D0\">&quot;date&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">2023-01-01<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">value<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">26813.6<\/span><span style=\"color: #A3BE8C\">},<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">{<\/span><span style=\"color: #88C0D0\">&quot;date&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">2023-04-01<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">value<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">27063.0<\/span><span style=\"color: #A3BE8C\">},<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">{<\/span><span style=\"color: #88C0D0\">&quot;date&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">2023-07-01<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">value<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">27357.8<\/span><span style=\"color: #A3BE8C\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  &#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># A reqeuest like this clearly bennefits from concurrent reqeuests and background data merging.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">reserve<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">fetch<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">series<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">GDP<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">CPIAUCSL<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">UNRATE<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">FEDFUNDS<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">PCE<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">--with-obs<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">--concurrency<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">8<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Mixed Workflows<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>reserve fetch series GDP CPIAUCSL &#8211;store<\/li>\n<\/ul>\n\n\n\n<p>In these cases, each series is fetched independently and concurrently.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Where Concurrency Is Not Used<\/strong><\/h2>\n\n\n\n<p>Concurrency is <strong>not applied<\/strong> to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Single-series requests<\/li>\n\n\n\n<li>Category, release, source, and tag browsing<\/li>\n\n\n\n<li>Local transformations (transform, window)<\/li>\n\n\n\n<li>Statistical analysis (analyze)<\/li>\n\n\n\n<li>Terminal rendering (chart)<\/li>\n\n\n\n<li>Local database writes (intentionally batched)<\/li>\n<\/ul>\n\n\n\n<p>These operations are either:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>not network-bound<\/li>\n\n\n\n<li>already efficient<\/li>\n\n\n\n<li>or designed to remain deterministic and simple<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Rate Limiting and Safety<\/strong><\/h2>\n\n\n\n<p>Concurrency is combined with <strong>client-side rate limiting<\/strong>.  The following config.json values translate to 8 concurrent requests limited to 5 requests per second:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>  \"concurrency\": 8,\n  \"rate\": 5,<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;concurrency&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">8<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #88C0D0\">&quot;rate&quot;<\/span><span style=\"color: #88C0D0\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">5<\/span><span style=\"color: #A3BE8C\">,<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Even if concurrency is increased, requests are still throttled to avoid overwhelming the FRED API.<\/p>\n\n\n\n<p>This means:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>concurrency controls <strong>parallelism<\/strong><\/li>\n\n\n\n<li>rate limiting controls <strong>request pace<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Together, they ensure safe and reliable API usage.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why Concurrency Improves Performance<\/strong><\/h2>\n\n\n\n<p>The performance gain comes from overlapping network latency.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Without concurrency<\/strong><\/h3>\n\n\n\n<p>Fetching 10 series:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>10 sequential HTTP requests<\/li>\n\n\n\n<li>total time = sum of all request latencies<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>With concurrency<\/strong><\/h3>\n\n\n\n<p>Fetching 10 series:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>multiple requests in flight simultaneously<\/li>\n\n\n\n<li>total time \u2248 slowest group of requests<\/li>\n<\/ul>\n\n\n\n<p>This can significantly reduce wall-clock time for batch operations.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>reserve fetch series GDP CPIAUCSL UNRATE FEDFUNDS --with-obs<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #88C0D0\">reserve<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">fetch<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">series<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">GDP<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">CPIAUCSL<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">UNRATE<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">FEDFUNDS<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">--with-obs<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>With concurrency:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>all series requests overlap<\/li>\n\n\n\n<li>total execution time is reduced<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Design Principles<\/strong><\/h2>\n\n\n\n<p>RESERVE uses a <strong>bounded concurrency model<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Fixed number of concurrent workers<\/li>\n\n\n\n<li>No unbounded fan-out<\/li>\n\n\n\n<li>Controlled resource usage<\/li>\n\n\n\n<li>Deterministic output ordering<\/li>\n<\/ul>\n\n\n\n<p>Failures are handled gracefully:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>partial results are returned<\/li>\n\n\n\n<li>warnings are collected per series<\/li>\n\n\n\n<li>one failure does not stop the entire batch<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>When to Adjust Concurrency<\/strong><\/h2>\n\n\n\n<p>Increase concurrency when:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>fetching many series<\/li>\n\n\n\n<li>working over high-latency networks<\/li>\n<\/ul>\n\n\n\n<p>Keep defaults when:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>working with small batches<\/li>\n\n\n\n<li>using rate-limited environments<\/li>\n<\/ul>\n\n\n\n<p>Higher values do not always mean faster results, especially when rate limits apply.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Summary<\/strong><\/h2>\n\n\n\n<p>Concurrency in RESERVE is:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>targeted at network-bound operations<\/li>\n\n\n\n<li>bounded and controlled<\/li>\n\n\n\n<li>safe through rate limiting<\/li>\n\n\n\n<li>deterministic in output<\/li>\n<\/ul>\n\n\n\n<p>It provides meaningful performance improvements for batch data workflows without sacrificing reliability or reproducibility.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>RESERVE achieves efficient batch data retrieval through controlled concurrency. RESERVE uses concurrency to improve performance when working with multiple FRED\u00ae series. Rather than fetching data one request at a time, RESERVE allows multiple network requests to be in flight simultaneously\u2014reducing total execution time for batch operations. Concurrency is intentionally scoped to network-bound workloads, where latency\u2014not &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/reservecli.dev\/documentation\/concurrency\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;concurrency&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":62,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"slim_seo":{"title":"concurrency - Reserve CLI","description":"RESERVE achieves efficient batch data retrieval through controlled concurrency. RESERVE uses concurrency to improve performance when working with multiple FRED\u00ae"},"footnotes":""},"class_list":["post-283","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/reservecli.dev\/wp-json\/wp\/v2\/pages\/283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reservecli.dev\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/reservecli.dev\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/reservecli.dev\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/reservecli.dev\/wp-json\/wp\/v2\/comments?post=283"}],"version-history":[{"count":4,"href":"https:\/\/reservecli.dev\/wp-json\/wp\/v2\/pages\/283\/revisions"}],"predecessor-version":[{"id":299,"href":"https:\/\/reservecli.dev\/wp-json\/wp\/v2\/pages\/283\/revisions\/299"}],"up":[{"embeddable":true,"href":"https:\/\/reservecli.dev\/wp-json\/wp\/v2\/pages\/62"}],"wp:attachment":[{"href":"https:\/\/reservecli.dev\/wp-json\/wp\/v2\/media?parent=283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}