2. What is Google App Engine. Overview Google App Engine (GAE) is a Platform as a Service (PaaS) cloud computing platform for developing and hosting web applications in Google-managed data centers. Google App Engine lets you run web applications on Google's infrastructure. Easy to build. Easy to maintain. Easy to scale as the traffic and storage needs grow. Free??? Yes, free for upto 1 GB of storage and enough CPU and bandwidth to support 5 million page views a month. 10 Applications per Google account.
Full stack web developer - develop application, also manage the server stack, implement a high availability system, configure a backup system, create a deployment system and a lot more. Having the knowledge of all these things is good, but having to do these every time you start a project can be annoying, specially if it is just a small side project.
PAAS PAAS will let you deploy an application without having to worry about the server management side of things. Depending on what PAAS you choose, they have features like Auto Scaling, easy deployment etc. More expensive than traditional Cloud Servers but will save you a lot of time and money in the long run. Heroku is the most popular PAAS
GAE Ease of Use take care of recompiling the application and reloading the webserver every time a file is changed. Pricing Reasonable have a free tier that is more than suitable for most small side projects Complete Management & Lots of Features removes server management from your todo list automatically does auto scaling and creates new instances as needed automatically handles high availability automatically distributes your application to Google s huge CDN network so that your service works really fast from anywhere in the globe ( side note : Google s CDN is the best) You are only charged for the resources you use and you do not have to worry about your service crashing Google s Infrastructure leverage the power of Google vast infrastructure True Cloud Security Infrastructure
CDN Content delivery network or content distribution network Globally distributed network of proxy servers deployed in multiple data centers. serve content to end-users with high availability and high performance
CDN Contd.
Proxy server A server that acts as an intermediary for requests from clients seeking resources from other servers
Proxy server A proxy server may reside on the user's local computer, or at various points between the user's computer and destination servers on the Internet. A proxy server that passes requests and responses unmodified is usually called a gateway or sometimes a tunneling proxy. Open Vs Reverse Proxies
An anonymous open proxy allows users to conceal their IP address while browsing the Web or using other Internet services. Response from the proxy server is returned as if it came directly from the original server, leaving the client no knowledge of the origin servers. Reverse proxy sits closer to the web server and serves only a restricted set of websites
Data anonymization Type of information sanitization whose intent is privacy protection. Process of either encrypting or removing personally identifiable information from data sets, so that the people whom the data describe remain anonymous. In the context of medical data, anonymized data refers to data from which the patient cannot be identified by the recipient of the information. The name, address, and full post code must be removed, together with any other information which, in conjunction with other data held by or disclosed to the recipient, could identify the patient.
Anonymizing Google s Server Log Data Google retain data to improve its services, uncover fraud etc but make it anonymous by anonymizing IP addresses in their server logs after 9 months Google Autocomplete To provide its recommendations Google Suggest needs to know what you've already typed, so these partial queries are sent to Google. for 98% of these requests, we don't log any data at all and simply return the suggestions. For the remaining 2% of cases (which we select randomly), we do log data, like IP addresses, in order to monitor and improve the service
Further on we decided that we will anonymize it within about 24 hours (basically, as soon as we practically can) in the 2% of Google Suggest requests we use Google Instant's partial query data for up to two weeks in unanonymized form, at which time we will delete 100 percent of it. These data retention changes apply only to queries made when Google Instant is active.
GAE Free Trial Free trial will start when you sign up for Google Cloud Platform. To sign up, sign in or create a Google Account. You will also need a credit card or bank account details so they can verify your identity. You will not be charged or billed during your free trial. After signing up, you might notice a $0.00 - $1.00 transaction from Google, which is a pending authorization request and is not an actual charge.
What's included in the free trial? $300 in credit to spend on all Google Cloud Platform products over 60 days. Your trial ends once 60 days have elapsed or you've spent $300. The amount of credit and days remaining are displayed at the top of the Google Cloud Platform Console. During the free trial, there are some product limitations. For example, when you launch virtual machines using Google Compute Engine, you can only run eight cores at a time.
Can I cancel my trial? If you want to leave the free trial, there's nothing to do. Your trial automatically expires after 60 days and you will not be charged during the free trial period unless you upgrade to a paid account.
What happens when my free trial ends? After your trial ends, the data and resources you created during the trial remain available for an additional 30 days. If you upgrade to a paid account in that 30-day window, you ll have access to those resources.
App limit Personal google account 10 Apps Institutional google account 25 Apps 7-day waiting period -- a project and associated data are permanently deleted
Steps 1. Downlaod SDK from https://cloud.google.com/sdk/docs/ 2. Extract the file 3. Run the install script./google-cloud-sdk/install.sh 4. Run gcloud init to initialize the SDK./google-cloud-sdk/bin/gcloud init 5. Clone the Hello World sample app repository to your local machine git clone https://github.com/googlecloudplatform/pythondocs-samples 6. Go to the directory that contains sample code cd python-docs-samples/appengine/standard/hello_world
Steps Contd. 7. From within the hello_world directory, start the local development server dev_appserver.py app.yaml 8. Visit http://localhost:8080/ in your web browser to view the app NOTE: You can leave the development server running while you develop your application. Development server watches for changes in your source files and reloads them if necessary.
Deploying app Run following command from within the root directory of your application where the app.yaml file is located: gcloud app deploy To launch your browser and view the app at http:// [YOUR_PROJECT_ID].appspot.com, run the following command: gcloud app browse NOTE: App Engine allows applications to be served via a custom domain, such as example.com, instead of an appspot.com address. You can use a custom domain with or without SSL.
Side note Build means to Compile the project. Deploy means to Compile the project & Publish the output
Thread safety is a computer programming concept applicable to multithreaded code. Thread-safe code only manipulates shared data structures in a manner that guarantees safe execution by multiple threads.
Using the Local Development Server Once you have a directory for your application and an app.yaml configuration file, you can start the local development server using the dev_appserver.py command. dev_appserver.py app.yaml To change which port the local server uses, use the --port option: dev_appserver.py --port=9999 app.yaml To browse local Datastore http://localhost:8000/datastore
App.yaml Specifies how URL paths correspond to request handlers and static files
runtime: Required. The name of the App Engine runtime environment used by this application. To specify Python, use python27.
api_version : Required. The version of the API in the given runtime environment used by this application. When Google releases a new version of a runtime environment's API, your application will continue to use the one for which it was written. To upgrade your application to the new API, you change this value and upload the upgraded code. At this time, App Engine has one version of the python27 runtime environment: 1
Side Note Just as a graphical user interface makes it easier for people to use programs, application programming interfaces make it easier for developers to use certain technologies in building applications. API is a set of clearly defined methods of communication between various software components
Threadsafe : Required. Configures your application to use concurrent requests. If using Python's threading library, the thread-local data, as returned by threading.local(), is cleared after each request. threadsafe: [true false] threadsafe: true requires that all script handlers be WSGI ones. That is, each script must be specified in a script: directive using Python module path, with package names separated by dots.
script: directive can contain either a file path ending in.py, which means the script uses CGI, or a Python module path, with package names separated by dots, which means the script uses WSGI. CGI : The common gateway interface (CGI) is a standard way for a Web server to pass a Web user's request to an application program and to receive data back to forward to the user. WSGI : a specification for simple and universal interface between web servers and web applications or frameworks for the Python programming language
Handlers: Required. A list of URL patterns and descriptions of how they should be handled. App Engine can handle URLs by executing application code, or by serving static files uploaded with the code, such as images, CSS, or JavaScript.
A script: directive must be a python import path
Scaling
automatic_scaling : F1, F2, F4, and F4_1G instance classes are available. Automatic scaling is assumed by default with a default instance class of F1 unless specified otherwise. basic_scaling: B1, B2, B4, B4_1G, and B8 instance classes are available. Default: B2 manual_scaling: B1, B2, B4, B4_1G, and B8 instance classes are available. Default: B2
max_concurrent_requests: The number of concurrent requests an automatic scaling instance can accept before the scheduler spawns a new instance (Default: 8, Maximum: 80). max_idle_instances: maximum number of idle instances that App Engine should maintain for this version. Note: When settling back to normal levels after a load spike, the number of idle instances can temporarily exceed your specified maximum. However, you will not be charged for more instances than the maximum number you've specified. max_pending_latency: The maximum amount of time that App Engine should allow a request to wait in the pending queue before starting a new instance to handle it. The default value is "30ms".
min_idle_instances: A low minimum helps keep your running costs down during idle periods, but means that fewer instances might be immediately available to respond to a sudden load spike. A high minimum allows you to prime the application for rapid spikes in request load. If you set a minimum number of idle instances, pending latency will have less effect on your application's performance. Because App Engine keeps idle instances in reserve, it is unlikely that requests will enter the pending queue except in exceptionally high load spikes
min_pending_latency: minimum amount of time that App Engine should allow a request to wait in the pending queue before starting a new instance to handle it. A low minimum means requests must spend less time in the pending queue when all existing instances are active. This improves performance but increases the cost of running your application. A high minimum means requests will remain pending longer if all existing instances are active. This lowers running costs but increases the time users must wait for their requests to be served.
Basic Scaling sets the number of instances for a service. max_instances: Required. The maximum number of instances for App Engine to create for this service version. This is useful to limit the costs of a service. idle_timeout : Optional. The instance will be shut down this amount of time after receiving its last request. Default is 5 minutes.
Manual Scaling instances The number of instances to assign to the service at the start.
Instance classes
Pricing App Engine standard environment gives you 1 GB of data storage and traffic for free
Homework Creating a Guestbook Application using GAE https://cloud.google.com/appengine/do cs/standard/python/gettingstarted/creating-guestbook