Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Eficiency and Low Cost: Pro Tips for you to save 50% of your money with Google Cloud

219 views

Published on

Eficiency and Low Cost: Pro Tips for you to save 50% of your money with Google Cloud

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Eficiency and Low Cost: Pro Tips for you to save 50% of your money with Google Cloud

  1. 1. P R O T I P S F O R Y O U T O S AV E 5 0 % O F Y O U R M O N E Y W I T H G O O G L E C L O U D E F F I C I E N C Y A N D L O W C O S T D A N I E L C U K I E R ( G D E ) @ D A N I C U K I
  2. 2. http://www.flickr.com/photos/zerial/2804865447/sizes/z/in/photostream/
  3. 3. http://www.flickr.com/photos/bike/266453254/sizes/l/in/photostream/
  4. 4. http://www.flickr.com/photos/tim_d/184018928/sizes/l/in/photostream/
  5. 5. http://www.flickr.com/photos/stars6/4381851322/sizes/l/in/photostream/
  6. 6. W H AT I F…
  7. 7. Click!
  8. 8. (╯°□°)╯︵ ┻━┻
  9. 9. Data Center Colocation Physical Servers Virtual Servers Managed Service Containers Managed Container App Engine Flex App Engine Standard SaaS Praia Low cost, high work High cost, low work W H E R E A R E Y O U ?
  10. 10. P R O T I P S F O R Y O U T O S AV E 5 0 % O F Y O U R M O N E Y W I T H G O O G L E C L O U D E F I C I E N C Y A N D L O W C O S T D A N I E L C U K I E R ( G D E ) @ D A N I C U K I
  11. 11. S U S TA I N E D U S A G E
  12. 12. C O M M I T E D U S E MACHINE TYPE ITEM FULL PRICE 1 YEAR COMMITMENT 3 YEAR COMMITMENT CUSTOM MACHINE TYPES VCPU $0.033174 / VCPU HOUR $0.019915 / VCPU HOUR $0.014225 / VCPU HOUR MEMORY $0.004446 / GB HOUR $0.002669 / GB HOUR $0.001907 / GB HOUR PREDEFINED MACHINE TYPES* N1- STANDARD-16 $0.7600 / HOUR $0.47878 / HOUR $0.34202 / HOUR N1- HIGHMEM-16 $0.9472 / HOUR $0.59622 / HOUR $0.42593 / HOUR N1- HIGHCPU-16 $0.5672 / HOUR $0.35707 / HOUR $0.25506 / HOUR
  13. 13. P R E E M P T I B L E http://www.agileandart.com/2016/05/04/how-i-reduced-my-cloud-cost-using-google-cloud/
  14. 14. S T E P 1 : S E T U P T H E C L I E N T T O B E FA U LT T O L E R A N T def query(params, retries = 0) { val response = api.query(params) response.onSuccess { codeForSuccess() } response.onFailure { case x => { LOG.error(s"Failure on $retries try of API request: " + x.getMessage) Thread.sleep(retries * 3000) // this sleep is optional query(params, retries + 1) // could have a maximum // number of retries here } } } P R E E M P T I B L E
  15. 15. S T E P 2 : P U T A L L S E R V E R S B E H I N D A L O A D B A L A N C E R #!/bin/bash SERVER_SUBSTRING=playax-fingerprint EMPTY_FILE=`cat /etc/haproxy/haproxy.cfg |grep -v $SERVER_SUBSTRING` NEW_LINES=`gcloud compute instances list |grep $SERVER_SUBSTRING | sed 's/ true//g' |sed 's/ [ ]*/ /g'|cut -d" " -f4|awk '{print " server playax- fingerprint" $NF " " $NF ":9000 check inter 5s rise 1 fall 1 weight 1"}'` echo "$EMPTY_FILE" >new_config echo "$NEW_LINES" >>new_config sudo cp new_config /etc/haproxy/haproxy.cfg sudo ./restart.sh P R E E M P T I B L E
  16. 16. S T E P 3 : C R E AT E A N I N S TA N C E G R O U P F O R T H E S E S E R V E R S P R E E M P T I B L E
  17. 17. P R E E M P T I B L E
  18. 18. P R E E M P T I B L E
  19. 19. P R E E M P T I B L E Price reduction:  $490 or 48.6% BEFORE AFTER SERVERS 20 24 COST PER SERVER $0.07 $0.03 TOTAL COST PER HOUR $1.4 $0.72 TOTAL COST PER MONTH $1,008 $518
  20. 20. F I L E S T O R A G E
  21. 21. Public Processed Long Term Storage Characteristics 99.95% availability
 Geo-redundant 99.9% availability
 Data stored in a narrow geographic region 99.0% availability
 30-day minimum storage duration 99.0% availability
 90-day minimum storage duration Uses Cases Frequently accessed World Audience Website content Streaming video Gaming Mobile Accessed by your system But not by your customers Big Data sets for processing Backup Long tail multimedia Disaster recovery Compliance archives Storage Cost
 GB/month $.026 $.02 $.01 $.007 Retrieval Cost
 GB $.01 $.05 Storage Type Multi-region Regional Nearline Coldline F I L E S T O R A G E
  22. 22. E X A M P L E $ g s u t i l d u - s g s : / / p l a y a x - re d u c e d / p ro d u c t i o n / d e t e c t i o n s F I L E S T O R A G E 1 4 , 7 1 9 , 8 0 0 , 9 6 2 , 9 0 4 = 1 3 , 7 0 8 G B Storage Type Multi-region Regional Nearline Coldline Cost GB/month $0.026 $0.02 $0.01 $0.007 Cost 2 years of data / month $356 $274 $137 $95 Cost 3 months of data / month $44 $34 $17 $12
  23. 23. P R E E M P T I B L E Price reduction:  $339 or 95.2% BEFORE AFTER GB OF DATA 13,708 2 COST / GB $0.026 $1000 COST / MONTH $356 $17
  24. 24. C O D E M AT T E R S
  25. 25. 2 9 6 7 5 , 1 4 3 7 6 , 5 5 9 5 0 , 2 5 8 6 , 8 0 9 9 5 , 3 7 7 5 9 , 6 5 8 4 5 , 3 1 5 6 2 , 1 5 8 0 0 , 4 2 7 7 5 , 9 6 5 4 2 , 2 1 4 8 5 , 9 3 7 2 8 , 5 9 0 2 2 , 7 8 8 5 4 , 9 6 6 8 , 3 1 0 8 8 , 4 4 0 0 7 , 4 1 8 7 8 , 2 7 6 8 0 , 5 4 4 5 0 , 9 1 3 3 6 , 1 9 2 8 1 , 1 7 0 2 5 , 7 4 9 7 8 , 3 3 9 4 2 , 2 4 6 8 9 , 2 7 2 9 1 , 5 7 0 2 4 , 3 1 9 4 7 , 9 5 7 3 9 , 9 0 7 9 4 , 2 8 6 2 4 , 7 6 6 0 2 , 5 9 6 2 7 , 4 8 0 7 7 , 6 4 4 6 4 , 2 7 6 2 8 , 2 2 9 9 , 4 0 9 9 8 , 3 6 0 9 9 , 1 7 9 1 , 2 1 5 6 3 , 2 9 0 7 8 , 5 8 8 4 4 , 3 2 9 5 1 , 8 1 1 0 5 , 9 9 0 3 1 , 2 2 3 8 9 , 2 2 5 4 9 , 2 8 6 9 , 2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aders()) { int p = 0; for(int i = 0; i < MAX; i++) { TermDocs td = sub.termDocs(new Term("fp", t)); int pos = td.read(docs, freqs); while(pos != 0) { for(int i = 0; i < pos; i++) { if(p >= alld.length) { alld = Arrays.copyOf(alld, alld.length * 2); } alld[p++] = docs[i]; } pos = td.read(docs, freqs); } td.close(); } if(p > 0) { Arrays.sort(alld, 0, p); int curr = alld[0]; int count = 0; for(int i = 0; i < p; i++) { int doc = alld[i]; if(doc == curr) { count++; } else { nHits++; curr += base; heapCheck(h, hsize, curr, count); curr = doc; count = 1; } } heapCheck(h, hsize, curr+base, count); } base += sub.maxDoc(); } O ( n l o g n )
  29. 29. IntIntMap countMap = new IntIntMap(6000000, 0.9f); for(IndexReader sub : reader.getSequentialSubReaders()) { for(String t : termSet) { TermDocs td = sub.termDocs(new Term("fp", t)); int pos = td.read(docs, freqs); while(pos != 0) { for(int i = 0; i < pos; i++) { countMap.addOne(docs[i] + base); if (docs[i] + base > max) { max = docs[i] + base; } } pos = td.read(docs, freqs); } td.close(); } base += sub.maxDoc(); } System.out.println("MAX: " + max); int nHits = countMap.size(); int[] data = countMap.getData(); for (int i = 0; i < data.length - 1; i = i + 2) { int key = data[i]; if (key != 0) { heapCheck(h, hsize, key, data[i+1]); } } O ( k n )
  30. 30. int[] countMap = new int[arraySize]; try { for (IndexReader sub : reader.getSequentialSubReaders()) { for (String t : termSet) { TermDocs td = sub.termDocs(new Term("fp", t)); int pos = td.read(docs, freqs); while (pos != 0) { for (int i = 0; i < pos; i++) { countMap[docs[i] + base]++; } pos = td.read(docs, freqs); } td.close(); } base += sub.maxDoc(); } } catch (ArrayIndexOutOfBoundsException e) { increaseArraySize(); return eval(reader, queryTerms, rb, rows, start); } int nHits = 0; for (int i = 0; i < countMap.length; i++) { if (countMap[i] > 0){ nHits++; heapCheck(h, hsize, i, countMap[i]); } } O ( n )
  31. 31. P R E E M P T I B L E Price reduction:  $2000 or 66.6% BEFORE AFTER NUMBER OF SERVERS 6 2 COST / MONTH $3000 $1000
  32. 32. R I G H T S I Z I N G R E C O M M E N D AT I O N S
  33. 33. E X T R A F O R S TA R T U S • Home Office > co-working > Office • Equity offers for developers • Used equipment and furniture at auctions websites • Government or universities programs (ex: startup Chile, Startup Brazil, PIPE-FAPESP, USA NSF-ISBIR, Israel OCS, etc.) • Use cloud providers programs for startups to save costs with infrastructure. Google, Rackspace, Microsoft, Amazon, and others offer until US$100.000 for one year. https://www.researchgate.net/publication/318429624
  34. 34. S TA R T U P C R E D I T S https://cloud.google.com/developers/startups/
  35. 35. L U C K
  36. 36. B E C R E AT I V E
  37. 37. W H AT A B O U T Y O U ? T W E E T T O @ D A N I C U K I W I T H # G C P S AV I N G S
  38. 38. D A7 F#m Lembro quando a vida era difícil F#m B7 Em A7 O servidor tinha vontade própria e dava pau F#m B7 Em O chefe reclamava o tempo inteiro G Em A7 D O senhor não vai gastar mais nenhum real A7 D Agora eu vou economizar A7 A7add4 A7 Mudei pra nuvem A7 G D A minha alma hoje é meu celular A7 A7add4 E todo o resto, todo resto A7 eu dei pro Google D Eles que cuidem D A7 D Economizar, D A7 G A7 D com Google Cloud você vai economizar D A7 D Economizar, D A7 G A7 D com Google Cloud sei que vou economizar D A7 D Foi numa manhã de 6a. feira D A7 D Que me deu um ataque de fúria B7 Em Arremecei um extintor A7 D No armário do servidor B7 E saí cortando Em todos os cabos de rede A7 D Explodi o roteador B7 Em Dei chute no monitor A7 D Joguei tudo na parede
  39. 39. “Nuvens… Hoje tenho consciência do céu, pois há dias em que não o olho mas sinto, vivendo na cidade e não na natureza que a inclui. Nuvens… São elas hoje a principal realidade, e preocupam- me como se o velar do céu fosse um dos grandes perigos de meu destino. Nuvens… Passam da barra para o Castelo, de Ocidente para Oriente, num tumulto disperso e despido, branco às vezes, se vão esfarrapadas na vanguarda de não sei o quê; meio-negro outras, se, mais lentas, tardam em ser varridas pelo vento audível; negras de um branco sujo, se, como se quisessem ficar, enegrecem mais da vinda que da sombra o que as ruas abrem de falso espaço entre as linhas fechadoras da casaria” Fernando Pessoa

×