传统API vs Serverless API:探索新兴的无服务器API开发模式

在当今数字化时代,企业对于灵活、可扩展且高效的技术解决方案的需求日益增长。无服务器计算(Serverless )作为一种新兴的架构模式,正在逐步改变人们对于传统服务器的认识。“无服务器”架构可以帮助开发者摆脱传统后端服务所带来的部署、运维成本,从而更加聚焦于业务逻辑的开发与迭代。

Serverless 的主要使用者是前端人员,而前端人员更关注开发工具,需要依赖开发工具进行 Serverless 开发、调试和部署。因此在API开发时,Serverless 具备先天的人才基础和使用基础。

根据传统的API开发程序,进行对Serverless API开发程序的优化操作

传统API的开发程序包括设计API的请求/响应数据的结构和字段,确定API的调用方式、url地址和参数类型等。主要通过专业开发人员编写代码来实现业务逻辑,如连接应用系统数据库、开放接口获取数据,处理异构系统协议转换、字段转换、安全控制和脱敏等。等到逻辑开发确定后,还需要补充API的接口功能、参数结构等使用说明文档,程序繁琐。

假设开发者要设计一个有道容器服务API监控。开发者要先使用API Monitor监控开源框架:https://gitee.com/ecar_team/apimonitor,进行模拟探测http接口、http页面,通过请求耗时和响应结果来判断系统接口的可用性和正确性。

开发者想要添加基础设施,还要添加Service级别API监控告警。以词典查词服务为例,开发者需要配置一条Service级别的多API监控(也可以是单API监控)。其中“所属系统”是服务所属的告警组,支持电话、短信、popo群、邮件等告警方式(和其它监控告警通用)。

传统API不仅依靠于前端和后端人员的辅助生成,还要经过多番测试进行模拟演练。对比之下,开发者使用Serverless API的话,能够在代码维护、架构创建等方面占据优势。

那么,开发者使用Serverless API开发模式时,由于Serverless 框架是一个开源 CLI 工具,它使代码部署变得更加容易且更可维护。它允许开发者将基础结构定义为代码(数据库、队列、文件存储、API 等),而不是手动登录通过 Web 接口创建它们,因此,开发者不需要管理运行代码的服务器,这消除了管理服务器、负载平衡器、应用补丁和扩展服务器的负担。

假设开发者要构建一个图书 API,该 API 将图书保存到一个 NoSQL 数据存储(DynamoDB)中,并将用于管理图书的 CRUD(创建、读取、更新和删除)。

首先打开Github地址: https://github.com/JamieLivingstone/serverless-node-rest-api。在电脑上安装全局 Serverless 框架“npm install -g serverless”,并创建一个新目录“book-api”、用代码编辑器打开。紧接着,在项目根目录下运行“serverless create –template aws-nodejs”命令生成新项目的框架。在项目根目录下新建一个文件“package.json”,并将下面的内容粘贴到这个文件中。

{
  "name": "book-app",
  "version": "1.0.0",
  "description": "Serverless book management API",
  "dependencies": {
    "@hapi/joi": "^15.0.3",
    "aws-sdk": "^2.466.0",
    "uuid": "^3.3.2"
  }
}

最后,在项目的根目录下运行如下命令安装项目依赖——“npm install”。从中可以看到,Serverless 框架简化了在代码中定义基础设施的过程,开发者可以在“serverless.yml”中配置应用程序基础参数。确定参数信息后,在项目根目录下创建一个新目录“books”。并在 books 目录下创建一个文件“schema.js”,就可以定义图书模式及其属性。

后无服务器时代,可以使用AWS Fargate为OpenCV项目创建无服务器API

进行传统API开发时,开发者要通过函数才能进行筛选、路由、批处理、拆分事件或调用其他云服务或函数,但现在这些操作等都能通过更少的函数代码,多数情况下甚至不需要函数代码就能完成;它们可以被可配置的云构造,以云服务一部分的形式取而代之。

云计算市场正在向超专业化的垂直多云服务转变,提供独特且高细粒度的功能,专业满足开发人员的需求。AWS的出现,将无需管理基础设施,即可根据事件执行代码的概念引入主流视线,开发者可以通过AWS,轻松实现函数代码到云构造的过渡。

以在带有AWS Fargate的无服务器容器中部署在OpenCV和Flask中创建的简单图像识别模型为例,开发者需要在CDK项目中部署的网络资源,打开网址https://medium.com/@JugueDev/despliega-laravel-usando-containers-serverless-con-aws-fargate-%EF%B8%8F-%EF%B8%8F-f4fdcb6c170f,并在Flask中创建一个超级基础的应用程序,创建一个hello_app.py文件,其中包含以下内容:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
 return 'Hello World!'

if __name__ == "__main__":
 app.run()。

接着,开发者需要在新创建的文件中定义requirements.txt项目的依赖关系:

Flask==2.0.2,并用Docker容器应用程序创建一个DockerFile。最后,把OpenCV应用程序连接到Flask项目,在requirement.txt文件中添加几个依赖项

click==8.0.3
Flask==2.0.2
itsdangerous==2.0.1
Jinja2==3.0.2
MarkupSafe==2.0.1
Werkzeug==2.0.2
numpy
keras
cmake==3.20.5
scikit-build==0.13.1
setuptools==50.3.2
wheel==0.30.0
tensorflow
opencv-python==4.4.0.46

图像构建成功后,开发者就可以继续将其上传到存储库中。并在AWS Fargate中部署图像到AWS Fargate的无服务器。

现行无服务器API的实操,以API Gateway为例

API Gateway是一个完全托管的服务,它使得开发者可以轻松创建、发布、维护、监控和保护任何规模的API。与Lambda结合使用时,API Gateway可以作为Lambda函数的前端触发器,接收HTTP请求并将其转发给Lambda函数处理,然后返回响应。

假设开发者要创建一个简单的API Gateway,需要遵循以下步骤:

  1. 在API Gateway控制台中,选择“创建API”。
  2. 选择“REST API”。
  3. 输入API名称,例如“HelloWorldAPI”。
  4. 在资源下创建一个新的资源,例如“/hello”。
  5. 为“/hello”资源创建一个GET方法。
  6. 将GET方法的集成类型设置为“Lambda函数”。
  7. 选择之前创建的Lambda函数。
  8. 部署API到一个新的阶段,例如“prod”。

这样,就可以创建一个公开的HTTP端点,当开发者访问这个端点时,API Gateway会触发Lambda函数,并将函数的响应返回给客户端。

此外,开发者还可以将Lambda和API Gateway结合起来,创建一个无服务器的HTTP API。用户的HTTP请求通过API Gateway路由到Lambda函数,函数处理请求后返回响应,整个过程无需服务器。

参考网站:

https://dreamit.blog.csdn.net/article/details/131746520

https://mp.weixin.qq.com/s/9T5HOXiDgOwgHuk9k1dVWg

https://mp.weixin.qq.com/s/8pnE8uK25jbvn433YdNs2w

https://mp.weixin.qq.com/s/IF_kVSUcujAAONwFoIPhvA

https://mp.weixin.qq.com/s/RadtEe09MYxZiK7DjuHbeg

https://mp.weixin.qq.com/s/qJh3Xexo3tzMQDYht5V5qQ

https://mp.weixin.qq.com/s/0RvSmFIR_Ao1auZ6w79D1g

Keyword: api开放平台

Encouraging Young Graduates To Get Excited About Manufacturing

Star Rapid is always happy to give back to the community that we call home. On Thursday July 6th, a group of 7 recent graduates from the Zhongshan Polytechnic University came to visit Star to understand more about manufacturing in a high-tech environment. In conjunction with the central government’s plan to encourage development in key industrial sectors, these young students and their peers are doing surveys of many companies throughout the region, compiling individual and group reports which they will then submit as part of a university competition.

The graduates who visited Star are all involved in the digital manufacturing and CNC training program, so they had a keen interest in experiencing first hand what it takes to run a world-class rapid prototyping and low-volume factory in their own city. They were impressed with the comprehensive and modern equipment we have on hand, just as we were impressed by their curiosity and enthusiasm. We’re always delighted to share what we do with the community and look forward to encouraging the next generation of makers. Congratulations Class of 2017!

Limited Edition White Gold Amazing Apples

Description

Golden bag filled with 400 premium White Gold nicotine pouches (2 Rolls/20 Cans) 16mg/g. Slim size 0,8 grams / pouch. Intense, refreshing taste of Apple.

Refillable can included.

See review from Snubie here.

BRAND: White Gold
CONTENT NET WEIGHT: 320g
PRODUCT TYPE: All white portion
FORMAT: Slim
STRENGTH: Strong
NICOTINE: 16 mg/g
FLAVOUR: Apple
WEIGHT PER POUCH: (GRAM) 0,8
MANUFACTURER: White Gold Pouch Sweden

掘金新援威少改穿4号 年轻小将拒绝让出0号

Click:chinese lantern film prop

Click:CNC machining

Click:12 watt led street light price

在今年夏天,拉塞尔·威斯布鲁克离开了洛杉矶快船队,以一份最低薪资合同加入了丹佛掘金队。然而,他并没有继续选择自己标志性的0号球衣,而是改穿4号。这一改变的背后故事是,掘金队的年轻球员布劳恩不愿意将自己身穿的0号球衣让渡给威斯布鲁克。

掘金随队记者Harrison Wind透露,威斯布鲁克曾希望能够延续他标志性的0号球衣,但当他向现穿0号球衣的布劳恩提出请求时,布劳恩却坚决拒绝了这一要求。与此不同,球队另一名球员泰森则主动将自己的4号球衣让给了威斯布鲁克,没有要求任何回报。

值得注意的是,4号球衣对威斯布鲁克来说具有特殊的意义。这不仅是他高中时的号码,还曾是他在奇才队时期的背号。威斯布鲁克曾解释说:“选择4号是因为它让我回忆起过去的比赛经历,提醒我为什么开始打篮球,并时刻让我想起我为谁而战以及我的家人。”

对掘金队而言,威斯布鲁克的加盟无疑是一个重要的补强,将为球队带来更多的经验和领导力。威斯布鲁克也表示,他将全力以赴,力争带领掘金队取得更好的成绩,为球迷们带来更多的胜利和喜悦。在掘金队的新赛季中,威斯布鲁克将继续追逐他的篮球梦想。

Keyword: NBA live

Bamboo Fiber Throw Blanket Sofa Blanket Baby Blanket Children&p

Click:silicone insulators

Click:澳洲風扇燈

Click:gold loan Auckland

Basic Info.

Model NO.
LW-BKT

Material
Cotton / Bamboo Fiber

Age Group
Children

Type
Cotton Blanket

Knitting Method
Machine Weaved

Pattern
Plain Color

Usage
Home

Color
White, Beige, Gray, Pink, Green, Blue

Transport Package
Plastic Bag and Export Carton

Specification
100% cotton

Trademark
LONGWAY

Origin
China

HS Code
5203000001

Production Capacity
5000PCS/Month

Product Description

Thermal Blanket

Material: 100% cotton or bamboo fiber

Color: various colors available, white, beige, green, blue, gray, brown, pink, etc. or according to customer requirements.

Sizes: 1.2M*1.5M/ 1.8M/2.2M/ Width can be upto 2.5m, accoridng to customer requirements;

Expedition Box Bed – Atlantic Blue

Why Buy Me? 
  • Inspired by outdoor clothing apparel
  • Robust, water-resistant outer fabric
  • Various colours and styles
  • 100% recycled filling
  • Machine Washable
Description

Inspired by outdoor clothing apparel, our Expedition range has been designed to appeal to pet owners who enjoy walking, travelling, and holidaying with their pets. Available in an assortment of colours and styles, Expedition beds are designed with a robust, water-resistant outer fabric which effortlessly deals with wet, muddy, or sandy paws. The box bed features a 100% recycled filling which provides enhanced cushioning, and the one-piece construction ensures additional strength and durability. Each bed is fully machine washable at 30°C.   

Our Expedition dog box bed is modelled by:

  • Jordan, a Cockapoo on the Large
  • Jax, a Cocker Spaniel on the Large
  • Charlie, a Beagle on the X Large
  • Bertie, a Black Labrador cross on the X Large
Material
  • Outer: 100% polyester
  • Base: 100% polyester
  • Fill: 100% recycled polyester
Washing Instructions
  • Do not bleach or tumble dry
  • Machine washable at 30°C
Size Information
  • Medium (60 x 50cm / 24″ x 19.5″)
  • Large (75 x 60cm / 29.5″ x 24″)
  • X-Large (90 x 70cm / 36″ x 27.5″)

 

Before ordering please ensure your chosen size is right for your dog. For guidance please see our Size Guide.

Please note: The images should not be used as a specific size representation, please make sure to refer to the size and measurement details to determine which size is suitable for your pet.

Keyword:

Chester Box Dog Bed – Chocolate Brown

Why Buy Me?
  • Super-soft short pile plush lines the dog beds sleep area
  • One-piece construction providing greater support
  • Non-slip base
  • Machine washable
    Description

      The Scruffs® Chester dog bed collection has been produced using a rich chenille fabric to upholster the outer of each bed. Luxurious, super-soft short pile plush lines the dog beds sleep area providing a snug environment for your pet. The beds are trimmed with faux suede piping and centre patch with an embroidered Scruffs® logo.

      As with nearly all Scruffs® beds, the Chester collection is machine washable and has a non-slip base.

      The box dog bed is made using a one-piece construction providing greater support and enhanced durability during washing.

      This is available in multiple sizes and colours.

      Our Chester dog box bed is modelled by:

      • Jordan, a Cockapoo on the Large
      • Charlie, a Beagle on the X Large
      • Charlie, a Chihuahua on the Medium 
      Material
      • Outer: 100% polyester
      • Inner: 100% polyester
      • Base: 100% polyester
      • Fill: 100% recycled polyester
      Washing Instructions
      • Machine Washable: The whole bed is Machine Washable at 30 degrees. However, this will depend on the size of the bed, larger beds may need a larger drum.
      • Do not bleach or tumble dry.
      Size Information
      • Small (50 x 40cm / 19.5″ x 16″)
      • Medium (60 x 50cm / 24″ x 19.5″)
      • Large (75 x 60cm / 29.5″ x 24″)
      • X-Large (90 x 70cm / 36″ x 27.5″)

       

      Before ordering please ensure your chosen size is right for your dog. For guidance please see our Size Guide.

      Please note: The images should not be used as a specific size representation, please make sure to refer to the size and measurement details to determine which size is suitable for your pet.

       

      Keyword:

      How to Use Karseell Collagen Hair Mask and Argan Oil for Best Re

      Discover how to use Karseell Collagen Hair Mask and Argan Oil to repair and nourish your hair for the best results. Transform your hair with these powerful products.

      Karseell Collagen Hair Treatment+Hair Mask Argan Oil Set Rated 4.97 out of 5 based on 160 customer ratings
      (161)
      $38.99

      Buy Now

      When it comes to restoring and nourishing damaged hair, the Karseell Collagen Hair Mask and Argan Oil duo is a game-changer. This powerful combination provides deep conditioning, repairs damaged strands, and promotes healthier, shinier hair. In this blog, we’ll walk you through the best way to use Karseell Collagen products to achieve optimal results.

      Step 1: Cleanse Your Hair Thoroughly

      Before using the Karseell Collagen Hair Mask, it’s important to start with clean hair. Use a gentle shampoo like Karseell shampoo to remove any dirt, oil, or styling product residue. This will allow the hair mask to penetrate your hair more effectively, ensuring the nutrients reach deep into the strands. For those with blonde or grey hair, consider using purple shampoo to eliminate any brassiness and enhance your natural shine.

      Step 2: Apply the Karseell Collagen Hair Mask

      After cleansing, towel-dry your hair to remove excess water, making it damp but not soaking wet. Now, it’s time to apply the Karseell Collagen Hair Mask. This mask is rich in collagen, a protein that helps to strengthen and rebuild damaged hair.

      For maximum benefit, leave the mask on for 10-15 minutes to allow the Karseell Collagen to fully absorb into your strands.

      Step 3: Rinse Thoroughly

      Once the Karseell Collagen Hair Mask has had time to work its magic, rinse it out thoroughly with lukewarm water. Be sure to rinse until your hair feels clean and free of any residue. The hair mask will leave your hair feeling silky smooth and deeply nourished.

      Step 4: Seal in the Moisture with Argan Oil

      To lock in the moisture and add a protective layer, follow up with Karseell Argan Oil. This hair oil is lightweight, packed with antioxidants, and known for its ability to promote hair growth and repair damage.

      The Argan Oil will leave your hair looking glossy and help reduce frizz throughout the day.

      Step 5: Style as Usual

      After applying the Argan Oil, you can proceed to style your hair as usual. Whether you prefer to air-dry or use heat tools, the combination of Karseell Collagen Hair Mask and Argan Oil will protect your hair from environmental damage while giving it a healthy shine. Plus, the hair oil will continue to nourish your hair throughout the day, helping to prevent breakage and split ends.

      How Often Should You Use the Karseell Collagen Hair Mask and Argan Oil?

      For best results, incorporate the Karseell Collagen Hair Mask into your routine 1-2 times a week, depending on your hair’s needs. If your hair is severely damaged or dry, using the mask twice a week can speed up the recovery process. Argan Oil can be used daily or as needed to keep your hair hydrated and smooth.

      Why Karseell Collagen and Argan Oil Work So Well Together

      The Karseell Collagen Hair Mask provides deep hydration and structural repair to your hair, while Argan Oil seals in moisture and adds a layer of protection. Together, they address both immediate damage and long-term hair health, resulting in softer, shinier, and healthier hair over time.

      Ready to transform your hair? Visit Karseell Collagen Hair Mask & Argan Oil Set to get started on your journey to beautiful hair today!

      By using Karseell Collagen and Argan Oil in your regular routine, you can achieve smoother, healthier hair that is free from damage. This combination is perfect for anyone looking to improve their hair’s texture and overall health.

      Keyword: ecolchi haircare

      Dainese Air-Maze Unisex Gloves

       

      Lightweight, comfortable, sports style gloves. The ventilated mesh construction encourages airflow for maximum comfort even on the hottest days. The reinforced synthetic palm offers excellent abrasion resistance. The back of the hand features additional reinforcements in soft material, increasing the level of protection without affecting the comfort and freedom of movement in the hand. The innovative construction with side stitching means there are no bothersome contact parts on the fingertips, providing even greater comfort. For maximum convenience, the fingers have Smart Touch inserts, so a rider can use a smartphone or GPS touchscreen system without removing their glove.

       

      CHARACTERISTICS:

      • Dainese Smart Touch
      • Soft inserts on the knuckles
      • Reinforced Thumb construction

       

      ERGONOMICS:

      • Adjustable cuff strap
      • Neoprene cuff
      • Pre-curved fingers

       

      MAIN MATERIALS:

      • Amica suede palm

       

      PERFORMANCE SHOCK:

      • Gloves certified to CE – Cat. II – EN 13594/2015 Standard cat. II lev. 1
      • PU leather reinforcements on the back
      • Reinforced palm

       

      TEMPERATURE:

      • Perforated mesh fabric on the fingers and back of the hand

      Related Products

      Dainese New Drake Air Tex Pants



      Skip to product compare


      bestsellers

      Dainese New Drake Air Tex Pants


      Starting at
      $489.99


      MSRP Price
      $489.99

      Save 0% Off MSRP

      Dainese Bora Gloves



      Skip to product compare


      sale

      Dainese Bora Gloves


      Starting at
      $97.49


      MSRP Price
      $129.99

      Save 25% Off MSRP

      Dainese D-Explorer 2 Gloves



      Skip to product compare


      sale

      Dainese D-Explorer 2 Gloves


      Starting at
      $142.49


      MSRP Price
      $189.99

      Save 25% Off MSRP

      Dainese Coimbra Unisex Windstopper Gloves



      Skip to product compare


      sale

      Dainese Coimbra Unisex Windstopper Gloves


      Starting at
      $135.99


      MSRP Price
      $169.99

      Save 20% Off MSRP

      Keyword: Motorcycle parts