Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

[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.

Davey Shafik

October 20, 2015
Tweet

More Decks by Davey Shafik

Other Decks in Programming

Transcript

  1. 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
  2. W H AT A R E C LO U D

    L E TS ? CC BY-ND 2.0
  3. 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
  4. C LO U D L E T P O L

    I C I E S CC-BY-SA 2.0: BrokenSphere
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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": { } } ],
  10. M ATC H E S "matches": [ { "matchType": "string",

    "matchValue": "string", "caseSensitive": boolean, "matchOperator": enum("contains", "exists", "equals"), "negate": boolean, "objectMatchValue": { } } ],
  11. 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
  12. 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; } }
  13. 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; } }
  14. E D G E R E D I R E

    CTO R CC-BY 2.0:
  15. 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
  16. M ATC H R U L E S • matchURL

    • redirectURL • statusCode • useIncomingQueryString
  17. 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; } } }
  18. 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) {
  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) {
  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) { throw $e; } $url = '/cloudlets/api/v2/policies'; $response = $this->client->get($url); foreach (json_decode($response->getBody()) as $policy) { if ($policy->name === 'developerdays') { break; } } }
  23. 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
  24. '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
  25. '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. 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; } }
  28. 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/', ] ], ];
  29. 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' ] ]);
  30. 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' ] ]);
  31. 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 }, … ]
  32. FO R W A R D R E W R

    I T E CC-BY 2.0:
  33. 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
  34. M ATC H R U L E S • matchURL

    • originId • useIncomingQueryString • forwardSettings • originId, pathAndQS, percent, useIncomingQueryString
  35. $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
  36. 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
  37. 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' ] ]);
  38. V I S I TO R P R I O

    R I T I Z AT I O N CC-BY 2.0:
  39. 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
  40. 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
  41. A P I P R I O R I T

    I Z AT I O N CC-BY 2.0:
  42. 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)
  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. 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
  45. M ATC H R U L E S • allowDeny:

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

    M E N TAT I O N CC-BY 2.0:
  47. 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
  48. M ATC H R U L E S • originId

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