[Akamai Edge 2015] Pushing it to the Edge with Akamai Cloudlets

[Akamai Edge 2015] Pushing it to the Edge with Akamai Cloudlets

Akamai has one of the worlds largest distribution platform, allowing you to push your content as close to your end users as possible — giving your users better response times, and offloading resources from your source. This is the Edge.

But can the Edge do more for you?

With Akamai Cloudlets we can push more than just content out to the Edge network, with more intelligence at the Edge we can provide faster experiences for our users without compromising on experience, or adding more resources.

Fee39f0c0ffb29d9ac21607ed188be6b?s=128

Davey Shafik

October 20, 2015
Tweet

Transcript

  1. DAV E Y S H A F I K

  2. P U S H I N G I T TO

    T H E E D G E W I T H A KA M A I C LO U D L E TS
  3. W H AT A R E C LO U D

    L E TS ? CC BY-ND 2.0
  4. W H AT A R E C LO U D

    L E TS ? • Small bit of application logic pushed to the edge • Save origin resources • Moves logic closer to your end-user • Changes can be deployed without deploying an entire policy
  5. C LO U D L E T P O L

    I C I E S CC-BY-SA 2.0: BrokenSphere
  6. C LO U D L E T P O L

    I C I E S Rule 1 Policy: myCloudlet Version: 1 Rule 2 Rule 3 Rule 4
  7. T I M E B OX E D CC-BY 2.0:

    S C H E D U L E W H E N P O L I C I E S A R E A P P L I E D
  8. P R O P E RTY M A N A

    G E R • Must be added as a rule in property manager (Luna) • Can be automated using PAPI
  9. M ATC H R U L E S • matchURL

    and/ or • matches • matchType • all (every request) • clientip • continent • cookie • countrycode • deviceCharacter istics • [file] extension • header • path • protocol • query • range • regex • regioncode
  10. M ATC H E S "matchRuleFormat" : "1.0", "matchRules": [

    { "name": "string", "type": "string" "start": timestamp, "end": timestamp, } ] "matches": [ { "matchType": "string", "matchValue": "string", "caseSensitive": boolean, "matchOperator": enum("contains", "exists", "equals"), "negate": boolean, "objectMatchValue": { } } ],
  11. M ATC H E S "matches": [ { "matchType": "string",

    "matchValue": "string", "caseSensitive": boolean, "matchOperator": enum("contains", "exists", "equals"), "negate": boolean, "objectMatchValue": { } } ],
  12. W O R K F LO W • Base URL:

    /cloudlets/api/v2 • GET /cloudlet-info • GET /group-info • POST /policies or GET /policies • PUT /policies/$policyId/versions/$version • POST /policies/$policyId/versions/$version/activations • Add rule to property manager • Activate configuration
  13. C LO U D L E T I N FO

    $url = '/cloudlets/api/v2/cloudlet-info'; $response = $client->get($url); $cloudlets = json_decode($response->getBody()); foreach ($cloudlets as $cloudlet) { if ($cloudlet->cloudletName == 'EDGEREDIRECTOR') { break; } }
  14. G R O U P I N F O $url

    = '/cloudlets/api/v2/group-info'; $response = $this->client->get($url); $groups = json_decode($response->getBody()); foreach ($groups as $group) { if (in_array(
 "daveyshafik.com", $group->properties )) { break; } }
  15. E D G E R E D I R E

    CTO R CC-BY 2.0:
  16. E D G E R E D I R E

    CTO R • Useful for large numbers of 301 and 302 rewrites • On the edge, avoiding a roundtrip to origin • Luna access can be limited to just rewrites for non-technical users • Can import a CSV
  17. M ATC H R U L E S • matchURL

    • redirectURL • statusCode • useIncomingQueryString
  18. CO D E CC-BY 2.0:

  19. C R E AT E P O L I C

    Y try { $url = '/cloudlets/api/v2/policies'; $response = $this->client->post($url, [ 'body' => json_encode([ 'cloudletId' => $cloudlet->cloudletId, 'groupId' => $group->groupId, 'name' => 'developerdays', 'description' => 'Redirect to the Developer Days site' ]), 'headers' => [ 'Content-Type' => 'application/json', ] ]); $policy = json_decode($response->getBody()); } catch (\GuzzleHttp\Exception\ClientException $e) { if ($e->getResponse()->getStatusCode() !== 409) { throw $e; } $url = '/cloudlets/api/v2/policies'; $response = $this->client->get($url); foreach (json_decode($response->getBody()) as $policy) { if ($policy->name === 'developerdays') { break; } } }
  20. C R E AT E P O L I C

    Y try { $url = '/cloudlets/api/v2/policies'; $response = $this->client->post($url, [ 'body' => json_encode([ 'cloudletId' => $cloudlet->cloudletId, 'groupId' => $group->groupId, 'name' => 'developerdays', 'description' => 'Redirect to the Developer Days site' ]), 'headers' => [ 'Content-Type' => 'application/json', ] ]); $policy = json_decode($response->getBody()); } catch (\GuzzleHttp\Exception\ClientException $e) { if ($e->getResponse()->getStatusCode() !== 409) {
  21. C R E AT E P O L I C

    Y try { $url = '/cloudlets/api/v2/policies'; $response = $this->client->post($url, [ 'body' => json_encode([ 'cloudletId' => $cloudlet->cloudletId, 'groupId' => $group->groupId, 'name' => 'developerdays', 'description' => 'Redirect to the Developer Days site' ]), 'headers' => [ 'Content-Type' => 'application/json', ] ]); $policy = json_decode($response->getBody()); } catch (\GuzzleHttp\Exception\ClientException $e) { if ($e->getResponse()->getStatusCode() !== 409) {
  22. C R E AT E P O L I C

    Y try { $url = '/cloudlets/api/v2/policies'; $response = $this->client->post($url, [ 'body' => json_encode([ 'cloudletId' => $cloudlet->cloudletId, 'groupId' => $group->groupId, 'name' => 'developerdays', 'description' => 'Redirect to the Developer Days site' ]), 'headers' => [ 'Content-Type' => 'application/json', ] ]); $policy = json_decode($response->getBody()); } catch (\GuzzleHttp\Exception\ClientException $e) { if ($e->getResponse()->getStatusCode() !== 409) {
  23. C R E AT E P O L I C

    Y try { $url = '/cloudlets/api/v2/policies'; $response = $this->client->post($url, [ 'body' => json_encode([ 'cloudletId' => $cloudlet->cloudletId, 'groupId' => $group->groupId, 'name' => 'developerdays', 'description' => 'Redirect to the Developer Days site' ]), 'headers' => [ 'Content-Type' => 'application/json', ] ]); $policy = json_decode($response->getBody()); } catch (\GuzzleHttp\Exception\ClientException $e) { if ($e->getResponse()->getStatusCode() !== 409) {
  24. C R E AT E P O L I C

    Y try { $url = '/cloudlets/api/v2/policies'; $response = $this->client->post($url, [ 'body' => json_encode([ 'cloudletId' => $cloudlet->cloudletId, 'groupId' => $group->groupId, 'name' => 'developerdays', 'description' => 'Redirect to the Developer Days site' ]), 'headers' => [ 'Content-Type' => 'application/json', ] ]); $policy = json_decode($response->getBody()); } catch (\GuzzleHttp\Exception\ClientException $e) { if ($e->getResponse()->getStatusCode() !== 409) { throw $e; } $url = '/cloudlets/api/v2/policies'; $response = $this->client->get($url); foreach (json_decode($response->getBody()) as $policy) { if ($policy->name === 'developerdays') { break; } } }
  25. try { $url = '/cloudlets/api/v2/policies'; $response = $this->client->post($url, [ 'body'

    => json_encode([ 'cloudletId' => $cloudlet->cloudletId, 'groupId' => $group->groupId, 'name' => 'developerdays', 'description' => 'Redirect to the Developer Days site' ]), 'headers' => [ 'Content-Type' => 'application/json', ] ]); $policy = json_decode($response->getBody()); } catch (\GuzzleHttp\Exception\ClientException $e) { if ($e->getResponse()->getStatusCode() !== 409) { throw $e; } $url = '/cloudlets/api/v2/policies'; $response = $this->client->get($url); foreach (json_decode($response->getBody()) as $policy) { if ($policy->name === 'developerdays') { break; } } } C R E AT E P O L I C Y
  26. 'headers' => [ 'Content-Type' => 'application/json', ] ]); $policy =

    json_decode($response->getBody()); } catch (\GuzzleHttp\Exception\ClientException $e) { if ($e->getResponse()->getStatusCode() !== 409) { throw $e; } $url = '/cloudlets/api/v2/policies'; $response = $this->client->get($url); foreach (json_decode($response->getBody()) as $policy) { if ($policy->name === 'developerdays') { break; } } } C R E AT E P O L I C Y
  27. 'headers' => [ 'Content-Type' => 'application/json', ] ]); $policy =

    json_decode($response->getBody()); } catch (\GuzzleHttp\Exception\ClientException $e) { if ($e->getResponse()->getStatusCode() !== 409) { throw $e; } $url = '/cloudlets/api/v2/policies'; $response = $this->client->get($url); foreach (json_decode($response->getBody()) as $policy) { if ($policy->name === 'developerdays') { break; } } } C R E AT E P O L I C Y
  28. 'headers' => [ 'Content-Type' => 'application/json', ] ]); $policy =

    json_decode($response->getBody()); } catch (\GuzzleHttp\Exception\ClientException $e) { if ($e->getResponse()->getStatusCode() !== 409) { throw $e; } $url = '/cloudlets/api/v2/policies'; $response = $this->client->get($url); foreach (json_decode($response->getBody()) as $policy) { if ($policy->name === 'developerdays') { break; } } } C R E AT E P O L I C Y
  29. G E T CU R R E N T V

    E RS I O N $version = 1; foreach ($policy->activations as $network) { if ($network->network === 'prod') { $version = (int) $network->policyInfo->version + 1; } }
  30. R E D I R E CT R U L

    E $rule = [ 'description' => 'Match edge URL', 'matchRuleFormat' => "1.0", 'matchRules' => [ [ 'name' => 'match-url', 'type' => 'erMatchRule', 'matchURL' => '/edge', 'statusCode' => 301, 'redirectURL' => 'http://akamaiapibootcamp.com/wordpress/', ] ], ];
  31. R E D I R E CT R U L

    E ( CO N T. ) $url = $policy->location . '/versions/' . $version; $response = $this->client->put($url, [ 'body' => json_encode($rule), 'headers' => [ 'Content-Type' => 'application/json' ] ]);
  32. A CT I VAT E P O L I C

    Y $policyVersion = json_decode($response->getBody()); $url = $policyVersion->location . '/activations'; $response = $this->client->post($url, [ 'body' => json_encode([ "network" => "prod", "additionalPropertyNames"=> [ "daveyshafik.com" ] ]), 'headers' => [ 'Content-Type' => 'application/json' ] ]);
  33. R E S P O N S E [ {

    "serviceVersion": null, "apiVersion": "2.0", "network": "prod", "policyInfo": { "policyId": int, "name": "developerdays", "version": 1, "status": "pending", "statusDetail": "File uploaded and awaiting validation", "detailCode": 1000, "activatedBy": "user.name", "activationDate": 1445323467000 }, … ]
  34. FO R W A R D R E W R

    I T E CC-BY 2.0:
  35. FO R W A R D R E W R

    I T E • Hide origin reorganization • Improve SEO by replacing long complex URLs with keyworded short URLs • On the edge, avoiding a roundtrip to origin
  36. M ATC H R U L E S • matchURL

    • originId • useIncomingQueryString • forwardSettings • originId, pathAndQS, percent, useIncomingQueryString
  37. CO D E CC-BY-SA 2.0:

  38. $rule = [ 'description' => 'Match Category URLs', 'matchRuleFormat' =>

    "1.0", "matchRules" => [ [ "name" => "categoryURLs", "type" => "frMatchRule", "matches" => [ [ "matchType" => "regex", "matchValue" => "(?:http|https)://example.org/(.*)/(.*)", "matchOperator" => "equals", ], ], "forwardSettings" => [ "pathAndQS" => "/render.php?\1=\2", "useIncomingQueryString" => false, ], ], ], ]; R E G E X R U L E
  39. ule = [ 'description' => 'Match Category URLs', 'matchRuleFormat' =>

    "1.0", "matchRules" => [ [ "name" => "categoryURLs", "type" => "frMatchRule", "matches" => [ [ "matchType" => "regex", "matchValue" => "(?:http|https)://example.org/(.*)/(.*)", "matchOperator" => "equals", ], ], "forwardSettings" => [ "pathAndQS" => "/render.php?\1=\2", "useIncomingQueryString" => false, ], ], ], R E G E X R U L E
  40. R E G E X R U L E (

    CO N T. ) $url = $policy->location . '/versions/' . $version; $response = $this->client->put($url, [ 'body' => json_encode($rule), 'headers' => [ 'Content-Type' => 'application/json' ] ]);
  41. V I S I TO R P R I O

    R I T I Z AT I O N CC-BY 2.0:
  42. V I S I TO R P R I O

    R I T I Z AT I O N • The “Waiting Room” • Allows you to send users to a customizable “waiting room” when resources are unavailable to handle dynamic requests on origin • Can be used to ease scaling events and traffic spikes • Reduce shopping cart abandonment
  43. M ATC H R U L E S • passThroughPercent

    • Send everyone to the waiting room: -1 • Range between 0.000% and 99.000% of users to pass to the waiting room • Send user to origin: 100
  44. A P I P R I O R I T

    I Z AT I O N CC-BY 2.0:
  45. A P I P R I O R I T

    I Z AT I O N • Serve static API responses from NetStorage • High availability • Prioritize access to the API for groups of users (e.g. paid vs free)
  46. M ATC H R U L E S • passThroughPercent

    • Send everyone to the waiting room: -1 • Range between 0.000% and 99.000% of users to pass to the waiting room • Send user to origin: 100
  47. I P/G E O ACC E SS

  48. I P/ G E O A CC E SS •

    Access Control based on IP or Geolocation • Black or white list • Allow internal-only access to pre-production sites • Allow partner-only access to sensitive content
  49. M ATC H R U L E S • allowDeny:

    ALLOW or DENY users when all conditions are true
  50. AU D I E N C E S E G

    M E N TAT I O N CC-BY 2.0:
  51. AU D I E N C E S E G

    M E N TAT I O N • Send users to different origins • Allows for gradual roll out of new features to different segments • A/B and Multivariant Testing • Layered experience: different experience for special or promotional purposes
  52. M ATC H R U L E S • originId

    • useIncomingQueryString • forwardSettings • originId, pathAndQS, percent, useIncomingQueryString