{"id":6884,"date":"2021-08-25T13:46:17","date_gmt":"2021-08-25T20:46:17","guid":{"rendered":"https:\/\/blogs.infoblox.com\/?p=6884"},"modified":"2021-08-25T13:46:17","modified_gmt":"2021-08-25T20:46:17","slug":"turbocharge-your-infoblox-restful-api-calls-part-2","status":"publish","type":"post","link":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/","title":{"rendered":"Turbocharge your Infoblox RESTful API calls (Part 2)"},"content":{"rendered":"<p class=\"g-lead\">In part 2 of Turbocharge your Infoblox RESTful API calls series, we discuss concurrency, its pros and cons, how it can be implemented to speed up automation scripts.<\/p>\n<h3>OVERVIEW<\/h3>\n<p>In this second article of the\u00a0<strong>Turbocharge your Infoblox RESTful API calls<\/strong>\u00a0series, we&#8217;ll take our synchronous Infoblox WAPI automation script and demonstrate how we can improve it by using concurrency to make it run faster. In this article we discuss what concurrency is, the pros and cons for using it in development, and how to implement it in our automation scripts. Recall that at a high level, scripts can be CPU-bound and\/or IO-bound. Scripts that are IO-bound are best refactored using concurrency techniques while CPU-bound scripts are best developed to take advantage of parallelism. Since our script is IO-bound (in the sense it has to wait for the network), we&#8217;ll focus on concurrency in this second article.<\/p>\n<p>The code used in development of this article series is accessible at\u00a0<a href=\"https:\/\/github.com\/ddiguru\/turbocharge_infoblox_api\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/ddiguru\/turbocharge_infoblox_api<\/a><\/p>\n<h3>Concurrency<\/h3>\n<p>Concurrency is defined as simultaneous occurrence. Python scripts accessing the Infoblox WAPI can be written to take advantage of concurrency through the use of threads, tasks, and processes. At a high level, they all refer to a sequence of instructions that run in that order. Threads, tasks and processes can be stopped at certain points of execution, and a computer&#8217;s CPU that is processing them can switch to a different one. The state of each one is saved so that it can be restarted, picking up where it left off. In this article, we focus on the use of Python threads.<\/p>\n<p>Characteristics of Python Threads:<\/p>\n<ul>\n<li>A Python thread runs on a single processor and therefore only run one at a time<\/li>\n<li>multiple threads w\/ the CPU doing context switching between threads makes code run faster<\/li>\n<li>the operating system knows about each thread and can interrupt at any time, i.e. pre-emptive multitasking<\/li>\n<li>Python threads run as sub-processes sharing the same global memory space<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6886\" src=\"https:\/\/blogs.infoblox.com\/wp-content\/uploads\/ddi-guru-turbo-2-image-1.jpg\" alt=\"\" width=\"900\" height=\"424\" srcset=\"https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/ddi-guru-turbo-2-image-1.jpg 900w, https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/ddi-guru-turbo-2-image-1-300x141.jpg 300w, https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/ddi-guru-turbo-2-image-1-768x362.jpg 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p>Concurrency can provide a modest improvement to our original script, since it encounters some degree of I\/O wait between each WAPI call to create a network. We will start with the original\u00a0<a href=\"https:\/\/github.com\/ddiguru\/turbocharge_infoblox_api\/blob\/main\/wapi-network.py\" target=\"_blank\" rel=\"noopener noreferrer\">wapi-network.py<\/a>\u00a0script and convert it to use Python Threads. As you probably guessed, re-writing our program to use threads will take some additional effort. When you add threading, the overall structure is the same and you only need to make a few changes.<\/p>\n<p>We will use Python&#8217;s\u00a0<strong><em>concurrent.futures<\/em><\/strong>\u00a0library to create a function or method which uses a list of items, our networks, to work on. The function will create a pool of 16 threads which will independently call an insert_network function. Each of the 16 threads in our script will appear to run in parallel, but instead, they will be controlled by the ThreadPoolExecutor, a part of the\u00a0<strong><em>concurrent.futures<\/em><\/strong>\u00a0library. The easiest way to create it is as a context manager, using the with statement to manage the creation and destruction of the pool. We&#8217;ll improve our original script first by importing the required module\u00a0<strong><em>concurrent.futures<\/em><\/strong>, then we&#8217;ll create the following runner function:<\/p>\n<pre><code class=\"language-python hljs\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">runner<\/span>(<span class=\"hljs-params\">networks<\/span>):<\/span>\r\n    threads = []\r\n    <span class=\"hljs-keyword\">with<\/span> ThreadPoolExecutor(max_workers=<span class=\"hljs-number\">16<\/span>) <span class=\"hljs-keyword\">as<\/span> executor:\r\n        <span class=\"hljs-keyword\">for<\/span> network <span class=\"hljs-keyword\">in<\/span> networks:\r\n            threads.append(executor.submit(insert_network, <span class=\"hljs-built_in\">str<\/span>(network)))\r\n\r\n        <span class=\"hljs-keyword\">for<\/span> task <span class=\"hljs-keyword\">in<\/span> as_completed(threads):\r\n            print(task.result())\r\n            <span class=\"hljs-keyword\">if<\/span> task.result() == <span class=\"hljs-number\">201<\/span>:\r\n                logger.info(<span class=\"hljs-string\">'thread successfully inserted network'<\/span>)\r\n            <span class=\"hljs-keyword\">else<\/span>:\r\n                logger.warning(<span class=\"hljs-string\">'thread failed to insert network'<\/span>)<\/code><\/pre>\n<p>Create a discrete function to insert a network object via the Infoblox WAPI as follows:<\/p>\n<pre><code class=\"language-python hljs\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">insert_network<\/span>(<span class=\"hljs-params\">network<\/span>):<\/span>\r\n    payload = <span class=\"hljs-built_in\">dict<\/span>(network=network, comment=<span class=\"hljs-string\">'test-network'<\/span>)\r\n    <span class=\"hljs-keyword\">try<\/span>:\r\n        res = s.post(<span class=\"hljs-string\">f'<span class=\"hljs-subst\">{url}<\/span>\/network'<\/span>, data=json.dumps(payload), verify=<span class=\"hljs-literal\">False<\/span>)\r\n        <span class=\"hljs-keyword\">return<\/span> res.status_code\r\n    <span class=\"hljs-keyword\">except<\/span> Exception <span class=\"hljs-keyword\">as<\/span> e:\r\n        <span class=\"hljs-keyword\">return<\/span> e<\/code><\/pre>\n<p>Here is the full listing to our new and improved script &#8211;\u00a0<a href=\"https:\/\/github.com\/ddiguru\/turbocharge_infoblox_api\/blob\/main\/wapi-threaded.py\" target=\"_blank\" rel=\"noopener noreferrer\">wapi-threaded.py<\/a><\/p>\n<p>The following graphically depicts how the script would execute, showing a much larger number of requests appearing to be simultaneously launched, with results being handled and returned as they are completed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6887\" src=\"https:\/\/blogs.infoblox.com\/wp-content\/uploads\/ddi-guru-turbo-2-image-2.jpg\" alt=\"\" width=\"552\" height=\"261\" srcset=\"https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/ddi-guru-turbo-2-image-2.jpg 552w, https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/ddi-guru-turbo-2-image-2-300x142.jpg 300w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/p>\n<div class=\"notices yellow\">\n<p>The example in this article is pretty simple and straight forward. Developing scripts in Python to use concurrency via threads can be much more difficult depending on the tasks. Complex business logic will likely require you to consider locking, race conditions, and\/or synchronization. It is beyond the scope of this article series to delve into all the gory details of concurrent programming using Python threads.<\/p>\n<\/div>\n<h3>Testing Results<\/h3>\n<p>We tested our original script\u00a0<a href=\"https:\/\/github.com\/ddiguru\/turbocharge_infoblox_api\/blob\/main\/wapi-network.py\" target=\"_blank\" rel=\"noopener noreferrer\">wapi-network.py<\/a>\u00a0against the new and improved threaded script\u00a0<a href=\"https:\/\/github.com\/ddiguru\/turbocharge_infoblox_api\/blob\/main\/wapi-threaded.py\" target=\"_blank\" rel=\"noopener noreferrer\">wapi-threaded.py<\/a>\u00a0using the same environment used in Part 1 of the series. Both scripts were tested both with and without HTTP Keepalive enabled on the Grid Master. The results without HTTP Keepalive (in seconds) are shown in the table below:<\/p>\n<div class=\"simple-responsive-table\">\n<div>\n<table>\n<thead>\n<tr>\n<th>Test w\/o HTTP Keepalive<\/th>\n<th>Pass #1<\/th>\n<th>Pass #2<\/th>\n<th>Pass #3<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>wapi-network.py<\/td>\n<td>39.88<\/td>\n<td>38.31<\/td>\n<td>38.87<\/td>\n<\/tr>\n<tr>\n<td>wapi-threaded.py<\/td>\n<td>25.98.81<\/td>\n<td>24.81<\/td>\n<td>24.57<\/td>\n<\/tr>\n<tr>\n<td><strong>% improvement<\/strong><\/td>\n<td><strong>34.85%<\/strong><\/td>\n<td><strong>25.24%<\/strong><\/td>\n<td><strong>36.79%<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>The Results with HTTP Keepalive (in seconds) are shown in the table below:<\/p>\n<div class=\"simple-responsive-table\">\n<div>\n<table>\n<thead>\n<tr>\n<th>Test w\/ HTTP Keepalive<\/th>\n<th>Pass #1<\/th>\n<th>Pass #2<\/th>\n<th>Pass #3<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>wapi-network.py<\/td>\n<td>33.85<\/td>\n<td>33.64<\/td>\n<td>33.33<\/td>\n<\/tr>\n<tr>\n<td>wapi-threaded.py<\/td>\n<td>19.47<\/td>\n<td>19.57<\/td>\n<td>20.28<\/td>\n<\/tr>\n<tr>\n<td><strong>% improvement<\/strong><\/td>\n<td><strong>42.48%<\/strong><\/td>\n<td><strong>41.83%<\/strong><\/td>\n<td><strong>39.16%<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>As shown in the above tables, the refactored\u00a0<a href=\"https:\/\/github.com\/ddiguru\/turbocharge_infoblox_api\/blob\/main\/wapi-threaded.py?_target=blank\">wapi-threaded.py<\/a>\u00a0script using Python Threads, dramatically outperforms our original\u00a0<a href=\"https:\/\/github.com\/ddiguru\/turbocharge_infoblox_api\/blob\/main\/wapi-network.py?_target=blank\">wapi-network.py<\/a>\u00a0script by a wide margin both with and without HTTP Keepalive. The wapi-threaded.py script (with Keepalive) executes in about 1\/2 the time as our wapi-network.py script (without Keepalive). Again, we&#8217;re able to achieve between 20% to 25% improvement in the performance of our new script just by enabling HTTP Keepalive.<\/p>\n<div class=\"notices blue\">\n<p>NOTE: As with all the examples in this series &#8211; there is a time and place for writing scripts to make use of Python threads to leverage concurrency, which turbocharges the performance of our script. The script in this article is a simple single tasking script and was easy to implement. Generally, you will have more complicated business logic that will make using threads more complex. It is not a panacea &#8211; but it does solve the problem of concurrency!<\/p>\n<\/div>\n<h3>Conclusion<\/h3>\n<p>In summary, we show again just how vital HTTP Keepalive can be to turbocharging our automation scripts that utilize the Infoblox WAPI. We refactored our original WAPI script to make use of Python threads, giving us an impressive 40% boost in performance. We strongly recommend you consider using Python threads to make your scripts take advantage of concurrency. The caveat is you will have to figure out the optimal number of threads to use, as well as, potentially handle more complex business logic and code as a result. In the next article,\u00a0<strong><em>Turbocharge your Infoblox RESTful API calls (part 3)<\/em><\/strong>, we&#8217;ll look at a powerful WAPI object called the\u00a0<em>request object<\/em>\u00a0which can be used to batch create our list of Networks using a single WAPI POST call.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In part 2 of Turbocharge your Infoblox RESTful API calls series, we discuss concurrency, its pros and cons, how it can be implemented to speed up automation scripts. OVERVIEW In this second article of the\u00a0Turbocharge your Infoblox RESTful API calls\u00a0series, we&#8217;ll take our synchronous Infoblox WAPI automation script and demonstrate how we can improve it [&hellip;]<\/p>\n","protected":false},"author":358,"featured_media":6885,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[3],"tags":[560,60,159,16],"class_list":{"0":"post-6884","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-community","8":"tag-restful-api-calls","9":"tag-wapi","10":"tag-automation","11":"tag-infoblox","12":"entry"},"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Turbocharge your Infoblox RESTful API calls (Part 2)<\/title>\n<meta name=\"description\" content=\"Turbocharge your Infoblox RESTful API calls (Part 2). In this second article of the Turbocharge your Infoblox RESTful API calls series, we&#039;ll take our synchronous Infoblox WAPI automation script and demonstrate how we can improve it by using concurrency to make it run faster. In this article we discuss what concurrency is, the pros and cons for using it in development, and how to implement it in our automation scripts. Recall that at a high level, scripts can be CPU-bound and\/or IO-bound. Scripts that are IO-bound are best refactored using concurrency techniques while CPU-bound scripts are best developed to take advantage of parallelism. Since our script is IO-bound (in the sense it has to wait for the network), we&#039;ll focus on concurrency in this second article.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Turbocharge your Infoblox RESTful API calls (Part 2)\" \/>\n<meta property=\"og:description\" content=\"Turbocharge your Infoblox RESTful API calls (Part 2). In this second article of the Turbocharge your Infoblox RESTful API calls series, we&#039;ll take our synchronous Infoblox WAPI automation script and demonstrate how we can improve it by using concurrency to make it run faster. In this article we discuss what concurrency is, the pros and cons for using it in development, and how to implement it in our automation scripts. Recall that at a high level, scripts can be CPU-bound and\/or IO-bound. Scripts that are IO-bound are best refactored using concurrency techniques while CPU-bound scripts are best developed to take advantage of parallelism. Since our script is IO-bound (in the sense it has to wait for the network), we&#039;ll focus on concurrency in this second article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Infoblox Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-25T20:46:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/ddi-guru-turbo-2-graphic.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Patrick Piper\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Patrick Piper\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/\"},\"author\":{\"name\":\"Patrick Piper\",\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/#\\\/schema\\\/person\\\/ac7cfb5c14c9216ae7cb53acfe37c1db\"},\"headline\":\"Turbocharge your Infoblox RESTful API calls (Part 2)\",\"datePublished\":\"2021-08-25T20:46:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/\"},\"wordCount\":1031,\"publisher\":{\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/wp-content\\\/uploads\\\/ddi-guru-turbo-2-graphic.jpg\",\"keywords\":[\"restful api calls\",\"WAPI\",\"automation\",\"Infoblox\"],\"articleSection\":[\"Community\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/\",\"url\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/\",\"name\":\"Turbocharge your Infoblox RESTful API calls (Part 2)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/wp-content\\\/uploads\\\/ddi-guru-turbo-2-graphic.jpg\",\"datePublished\":\"2021-08-25T20:46:17+00:00\",\"description\":\"Turbocharge your Infoblox RESTful API calls (Part 2). In this second article of the Turbocharge your Infoblox RESTful API calls series, we'll take our synchronous Infoblox WAPI automation script and demonstrate how we can improve it by using concurrency to make it run faster. In this article we discuss what concurrency is, the pros and cons for using it in development, and how to implement it in our automation scripts. Recall that at a high level, scripts can be CPU-bound and\\\/or IO-bound. Scripts that are IO-bound are best refactored using concurrency techniques while CPU-bound scripts are best developed to take advantage of parallelism. Since our script is IO-bound (in the sense it has to wait for the network), we'll focus on concurrency in this second article.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/wp-content\\\/uploads\\\/ddi-guru-turbo-2-graphic.jpg\",\"contentUrl\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/wp-content\\\/uploads\\\/ddi-guru-turbo-2-graphic.jpg\",\"width\":1200,\"height\":600},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/community\\\/turbocharge-your-infoblox-restful-api-calls-part-2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Community\",\"item\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/category\\\/community\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Turbocharge your Infoblox RESTful API calls (Part 2)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/\",\"name\":\"infoblox.com\\\/blog\\\/\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/#organization\",\"name\":\"Infoblox\",\"url\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/wp-content\\\/uploads\\\/infoblox-logo-2.svg\",\"contentUrl\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/wp-content\\\/uploads\\\/infoblox-logo-2.svg\",\"width\":137,\"height\":30,\"caption\":\"Infoblox\"},\"image\":{\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/#\\\/schema\\\/person\\\/ac7cfb5c14c9216ae7cb53acfe37c1db\",\"name\":\"Patrick Piper\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blogs.infoblox.com\\\/wp-content\\\/uploads\\\/avatar_user_358_1628788417-96x96.jpg\",\"url\":\"https:\\\/\\\/blogs.infoblox.com\\\/wp-content\\\/uploads\\\/avatar_user_358_1628788417-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/blogs.infoblox.com\\\/wp-content\\\/uploads\\\/avatar_user_358_1628788417-96x96.jpg\",\"caption\":\"Patrick Piper\"},\"description\":\"Patrick has over 24 years of experience in IT networking, with an emphasis on IP Address Management, DNS, and DHCP technologies. He graduated from N.C. State University with a BA in Business Management and was an All-American in Cross Country and Track. During his early work years following graduation, he took his running to the National level at the marathon distance, by qualifying for the 1994 Olympic Trials in just my first Marathon. Today, he appliesy the same hard work ethic and dedication that helped him be successful as an athlete to his IT consultancy. He has followed a well-planned job progression, starting as a systems engineer working with network operating systems and routing technologies. He advanced into consulting, where he learned how to effectively communicate and interact with technical and non-technical personnel on various large-scale IP services projects. In 1995, he founded Netlinx, Inc. originally as a systems integration firm focused on small business networking. Over the last 20 years his focus and emphasis has been on providing professional consulting and development services in the DDI space to large Enterprise firms. In 2012, he joined Wells Fargo &amp; Co. as the technical lead for the DDI Engineering team where he leads design, architecture, and engineering tasks as part of a large DDI reengineering project. In Aug. of 2014, he re-branded Netlinx, Inc. to DDI Guru, LLC, as a top-provider of DDI Engineering, Consulting, and Automation Services company.\",\"url\":\"https:\\\/\\\/www.infoblox.com\\\/blog\\\/author\\\/patrick-piper\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Turbocharge your Infoblox RESTful API calls (Part 2)","description":"Turbocharge your Infoblox RESTful API calls (Part 2). In this second article of the Turbocharge your Infoblox RESTful API calls series, we'll take our synchronous Infoblox WAPI automation script and demonstrate how we can improve it by using concurrency to make it run faster. In this article we discuss what concurrency is, the pros and cons for using it in development, and how to implement it in our automation scripts. Recall that at a high level, scripts can be CPU-bound and\/or IO-bound. Scripts that are IO-bound are best refactored using concurrency techniques while CPU-bound scripts are best developed to take advantage of parallelism. Since our script is IO-bound (in the sense it has to wait for the network), we'll focus on concurrency in this second article.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/","og_locale":"en_US","og_type":"article","og_title":"Turbocharge your Infoblox RESTful API calls (Part 2)","og_description":"Turbocharge your Infoblox RESTful API calls (Part 2). In this second article of the Turbocharge your Infoblox RESTful API calls series, we'll take our synchronous Infoblox WAPI automation script and demonstrate how we can improve it by using concurrency to make it run faster. In this article we discuss what concurrency is, the pros and cons for using it in development, and how to implement it in our automation scripts. Recall that at a high level, scripts can be CPU-bound and\/or IO-bound. Scripts that are IO-bound are best refactored using concurrency techniques while CPU-bound scripts are best developed to take advantage of parallelism. Since our script is IO-bound (in the sense it has to wait for the network), we'll focus on concurrency in this second article.","og_url":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/","og_site_name":"Infoblox Blog","article_published_time":"2021-08-25T20:46:17+00:00","og_image":[{"width":1200,"height":600,"url":"https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/ddi-guru-turbo-2-graphic.jpg","type":"image\/jpeg"}],"author":"Patrick Piper","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Patrick Piper","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/#article","isPartOf":{"@id":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/"},"author":{"name":"Patrick Piper","@id":"https:\/\/www.infoblox.com\/blog\/#\/schema\/person\/ac7cfb5c14c9216ae7cb53acfe37c1db"},"headline":"Turbocharge your Infoblox RESTful API calls (Part 2)","datePublished":"2021-08-25T20:46:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/"},"wordCount":1031,"publisher":{"@id":"https:\/\/www.infoblox.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/ddi-guru-turbo-2-graphic.jpg","keywords":["restful api calls","WAPI","automation","Infoblox"],"articleSection":["Community"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/","url":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/","name":"Turbocharge your Infoblox RESTful API calls (Part 2)","isPartOf":{"@id":"https:\/\/www.infoblox.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/#primaryimage"},"image":{"@id":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/ddi-guru-turbo-2-graphic.jpg","datePublished":"2021-08-25T20:46:17+00:00","description":"Turbocharge your Infoblox RESTful API calls (Part 2). In this second article of the Turbocharge your Infoblox RESTful API calls series, we'll take our synchronous Infoblox WAPI automation script and demonstrate how we can improve it by using concurrency to make it run faster. In this article we discuss what concurrency is, the pros and cons for using it in development, and how to implement it in our automation scripts. Recall that at a high level, scripts can be CPU-bound and\/or IO-bound. Scripts that are IO-bound are best refactored using concurrency techniques while CPU-bound scripts are best developed to take advantage of parallelism. Since our script is IO-bound (in the sense it has to wait for the network), we'll focus on concurrency in this second article.","breadcrumb":{"@id":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/#primaryimage","url":"https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/ddi-guru-turbo-2-graphic.jpg","contentUrl":"https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/ddi-guru-turbo-2-graphic.jpg","width":1200,"height":600},{"@type":"BreadcrumbList","@id":"https:\/\/www.infoblox.com\/blog\/community\/turbocharge-your-infoblox-restful-api-calls-part-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.infoblox.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Community","item":"https:\/\/www.infoblox.com\/blog\/category\/community\/"},{"@type":"ListItem","position":3,"name":"Turbocharge your Infoblox RESTful API calls (Part 2)"}]},{"@type":"WebSite","@id":"https:\/\/www.infoblox.com\/blog\/#website","url":"https:\/\/www.infoblox.com\/blog\/","name":"infoblox.com\/blog\/","description":"","publisher":{"@id":"https:\/\/www.infoblox.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.infoblox.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.infoblox.com\/blog\/#organization","name":"Infoblox","url":"https:\/\/www.infoblox.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.infoblox.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/infoblox-logo-2.svg","contentUrl":"https:\/\/www.infoblox.com\/blog\/wp-content\/uploads\/infoblox-logo-2.svg","width":137,"height":30,"caption":"Infoblox"},"image":{"@id":"https:\/\/www.infoblox.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.infoblox.com\/blog\/#\/schema\/person\/ac7cfb5c14c9216ae7cb53acfe37c1db","name":"Patrick Piper","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blogs.infoblox.com\/wp-content\/uploads\/avatar_user_358_1628788417-96x96.jpg","url":"https:\/\/blogs.infoblox.com\/wp-content\/uploads\/avatar_user_358_1628788417-96x96.jpg","contentUrl":"https:\/\/blogs.infoblox.com\/wp-content\/uploads\/avatar_user_358_1628788417-96x96.jpg","caption":"Patrick Piper"},"description":"Patrick has over 24 years of experience in IT networking, with an emphasis on IP Address Management, DNS, and DHCP technologies. He graduated from N.C. State University with a BA in Business Management and was an All-American in Cross Country and Track. During his early work years following graduation, he took his running to the National level at the marathon distance, by qualifying for the 1994 Olympic Trials in just my first Marathon. Today, he appliesy the same hard work ethic and dedication that helped him be successful as an athlete to his IT consultancy. He has followed a well-planned job progression, starting as a systems engineer working with network operating systems and routing technologies. He advanced into consulting, where he learned how to effectively communicate and interact with technical and non-technical personnel on various large-scale IP services projects. In 1995, he founded Netlinx, Inc. originally as a systems integration firm focused on small business networking. Over the last 20 years his focus and emphasis has been on providing professional consulting and development services in the DDI space to large Enterprise firms. In 2012, he joined Wells Fargo &amp; Co. as the technical lead for the DDI Engineering team where he leads design, architecture, and engineering tasks as part of a large DDI reengineering project. In Aug. of 2014, he re-branded Netlinx, Inc. to DDI Guru, LLC, as a top-provider of DDI Engineering, Consulting, and Automation Services company.","url":"https:\/\/www.infoblox.com\/blog\/author\/patrick-piper\/"}]}},"_links":{"self":[{"href":"https:\/\/www.infoblox.com\/blog\/wp-json\/wp\/v2\/posts\/6884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infoblox.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infoblox.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infoblox.com\/blog\/wp-json\/wp\/v2\/users\/358"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infoblox.com\/blog\/wp-json\/wp\/v2\/comments?post=6884"}],"version-history":[{"count":2,"href":"https:\/\/www.infoblox.com\/blog\/wp-json\/wp\/v2\/posts\/6884\/revisions"}],"predecessor-version":[{"id":6889,"href":"https:\/\/www.infoblox.com\/blog\/wp-json\/wp\/v2\/posts\/6884\/revisions\/6889"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.infoblox.com\/blog\/wp-json\/wp\/v2\/media\/6885"}],"wp:attachment":[{"href":"https:\/\/www.infoblox.com\/blog\/wp-json\/wp\/v2\/media?parent=6884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infoblox.com\/blog\/wp-json\/wp\/v2\/categories?post=6884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infoblox.com\/blog\/wp-json\/wp\/v2\/tags?post=6884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}