Readings: Serverless Functions
(notes credit from this source: https://www.ibm.com/cloud/learn/serverless) (https://pymotw.com/3/http.server/index.html)
- What is serverless? ```angular2html A serverless function is a programmatic function written by a software developer for a single purpose. it’s hosted and maintained on cloud infrastructure companies like Amazon AWS and Microsoft Azure. Users don’t need to worry about code maintenance and execution environment, cloud take care of all that.
**Pros**
- Improved developer productivity
- Pay for only execution time
- Multi programming languages support
- Simplified DevOps cycles
- Easy scaling
- cost on your own choice
- visualized user center console FYI
**Cons**
- Unacceptable latency when start from zero or start over
- High costs for stable workloads
- monitor and debug issues is hard as platform less support popular tools and processes
- code trans platforms is hard.
### Http server
- http.server uses classes from socketserver to create base classes for making HTTP servers.
- BaseHTTPRequestHandler can handle each protocol method (GET, POST, etc.).
**Get( ) method sample code**
class handler(BaseHTTPRequestHandler):
```angular2html
def do_GET(self):
self.send_response(200)
self.send_header("content-type", "text/plain")
self.end_headers()
message = "please follow format 'country=name'"
self.wfile.write(message.encode())
return
Requests
- Requests allow users to send HTTP/1.1 requests extremely easy, together with
urllib3
, we can”Keep-Alive & Connection Pooling”.
Vercel
- an international version fo Netlify, support serverless functions deployment.
Things I want to know more: How is the serverless platform debugging works?