title: How to send multi POST request via CURL at same time on PHP? (over 2.000 requests)
body: <p>Well, i need <strong>send multiple http post request</strong>(over 2500) and get result via Curl(php or command), but i dont know whats it the best and better way to send it..</p>
  
  <p>In the query that I send, also I have to send the "javax.faces.ViewState" parameter that has about 150,000 and characters(arround of )...</p>
  
  <p>i have a example code for understand and see how it work:</p>
  
  <pre><code>&lt;?php
  // i need send especific data via post
  // and this data have a combination between internal id and year(from 2005 to current[2015])
  $ids            =   array("988","992","6","989","993","14","26","948","949","950","951","952","27","34","386","953","954","955","956","47","51","53","927","928","929","930","931","933","932","88","94","103","660","1045","1046","1047","1049","1050","1051","1052","1053","1054","1055","1056","1057","1058","1059","1060","1061","1062","1048","114","119","1063","1064","1065","1067","1068","1069","1070","1097","1151","1150","1071","127","132","140","957","959","960","961","962","963","964","965","966","967","968","958","150","151","152","1072","1073","1074","1093","157","158","159","160","188","189","190","195","385","1075","1076","1077","1078","1079","1080","1081","1082","1083","1094","193","1152","1325","1326","206","207","209","214","216","934","935","936","937","938","939","940","941","942","943","944","946","947","223","225","226","227","1084","1085","1086","1087","1088","1095","1251","240","241","244","245","659","662","1089","1090","1091","1092","1096","1328","1013","248","249","250","990","994","996","257","258","991","995","1220","1221","1222","1223","1224","1225","1226","1227","1228","1232","1233","1235","1244","1245","1246","1247","1248","1250","1321","1229","1230","1231","1234","1236","1237","1238","1239","1240","1249","1320","1322","1323","1355");
  $startYear      =   2005;
  $currentYear    =   intval(date("Y"));
  // this is "javax.faces.ViewState" a param with between 50.000 to 150.000 characters
  $javaxFacesViewState = "H4sIAAAAAAAAAOy9CWAcSXkv3josWT5l+dxb7OXdxZYszSFpvSyMRrI09ujYmZGMvYBozbQ0bc1Mj3t6dJh/uF5CDkKAAAkECBAWSAjkgBCW5WaBQMJNSEhCwhneIy8hLwTCJnmw//qqr+qjprur24t3nw3b6qnjV1Vffd9XX3119Dv+hdvWkLm7JHl1gL/Ab8YvNFYG+Hq9IhZ5RZRqAwVZEPKK3CwqTVmYlUrCC1/6r69+eOWW7bs4brN+ieM6Oe4WS+6iVK1LNaGmDKRQ0KIobOQkSeF6..... ... ...";
  
  // So, i dont have more server, i have only one, so i think use a proxy list over 50 ips
  $proxyList      =   array(
      "xxx.xx.x.x:8080",
      "xxx.xx.x.x:2353",
      "xxx.xx.x.x:80",
      "xxx.xx.x.x:434",
      //...
      //...
  );
  echo "&lt;ul&gt;";
  $index = 1;
  for ($i = 0; $i &lt; count($ids); $i++) {
      echo "&lt;li&gt;";
          echo "&lt;strong&gt;ID: &lt;em&gt;".$ids[$i]."&lt;/em&gt;&lt;/strong&gt;";
          echo "&lt;ol&gt;";
          for ($y = $startYear; $y &lt;= $currentYear; $y++) {
              echo "&lt;li value='$index'&gt;Year: $y; curl command:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;curl --proxy ".$proxyList[array_rand($proxyList)]." http://example.com/information.jsp --data=id=".$ids[$i]."&amp;year=$y$y&amp;javax.faces.ViewState=$javaxFacesViewState...&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;";
              $index++;
          }
          echo "&lt;/ol&gt;";
      echo "&lt;/li&gt;";
  }
  echo "&lt;/ul&gt;";
  echo "&lt;h1&gt;Total request: ".number_format($index,0)."&lt;/h1&gt;";
  ?&gt;
  </code></pre>
  
  <p>The output is like to:</p>
  
  <ul>
  <li>ID: 988
  
  <ol>
  <li>Year: 2005; curl command: <code>curl --proxy xxx.xx.x.x:455 http://example.com/information.jsp --data=id=12&amp;year=2005&amp;...</code></li>
  <li>Year: 2005; curl command: <code>curl --proxy xxx.xx.x.x:80 http://example.com/information.jsp --data=id=23&amp;year=2005&amp;...</code></li>
  <li>Year: 2005; curl command: <code>curl --proxy xxx.xx.x.x:8080 http://example.com/information.jsp --data=id=4556&amp;year=2005&amp;...</code></li>
  <li>Year: 2005; curl command: <code>curl --proxy xxx.xx.x.x:235 http://example.com/information.jsp --data=id=34&amp;year=2005&amp;...</code></li>
  <li>...</li>
  <li>...</li>
  </ol></li>
  </ul>
  
  <p>Total request: 2,135</p>
  
  <p>So, i need send multi post request on minimal time... whats is the best and better way for it? </p>
  
  <p>My server is a (MT) - DV LVL 1:</p>
  
  <ul>
  <li>2GB RAM</li>
  <li>2TB bandwidth</li>
  <li>CentOS 6</li>
  </ul>
  
  <p><strong>less /proc/cpuinfo</strong></p>
  
  <pre><code>[root ~]# less /proc/cpuinfo
  processor       : 0
  vendor_id       : GenuineIntel
  cpu family      : 6
  model           : 62
  model name      : Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz
  stepping        : 4
  microcode       : 1064
  cpu MHz         : 2094.833
  cache size      : 15360 KB
  physical id     : 0
  siblings        : 12
  core id         : 0
  cpu cores       : 6
  apicid          : 0
  initial apicid  : 0
  fpu             : yes
  fpu_exception   : yes
  cpuid level     : 13
  wp              : yes
  flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf cpuid_faulting pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt
  bogomips        : 4189.66
  clflush size    : 64
  cache_alignment : 64
  address sizes   : 46 bits physical, 48 bits virtual
  power management:
  
  processor       : 1
  vendor_id       : GenuineIntel
  cpu family      : 6
  model           : 62
  model name      : Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz
  stepping        : 4
  </code></pre>
  
  <ul>
  <li>PHP: 5.4.13</li>
  <li>Curl: 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7
  NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2</li>
  <li>Apache: 2.2.15 (Unix)</li>
  <li>iptables: 1.4.7</li>
  </ul>
  
  <p>Thanks</p>