The right posture for developing functional computing - running Selenium Java

foreword

First, let's introduce some of the more important concepts that appear in this article:

Function Compute : Function Compute is an event-driven service. With Function Compute, users do not need to manage the operation of the server, but only need to write code and upload it. Function Compute prepares computing resources and runs user code in an elastically scalable manner, and users only pay for the resources consumed by the actual code running. See Function Compute for more information . Fun : Fun is a tool for supporting serverless application deployment, which can help you conveniently manage resources such as function computing, API gateway, log service, etc. It assists you in developing, building, and deploying through a resource configuration file (template.yml). More documentation reference for Fun .

Note: The techniques described in this article require Fun version 2.10.2 or greater.

Dependent tool

This project is developed under MacOS, and the tools involved are platform-independent, and should be equally applicable to Linux and Windows desktop systems. Before starting this example, please make sure that the following tools have been installed correctly, updated to the latest version, and configured correctly.

The Fun and Fcli tools rely on docker to simulate a local environment.

For MacOS users you can use homebrew to install:

brew cask install docker
brew tap vangie/formula
brew install fun
brew install fcli

For Windows and Linux users, please refer to:

  1. https://github.com/aliyun/fun/blob/master/docs/usage/installation.md
  2. https://github.com/aliyun/fcli/releases

After installation, remember to execute fun configInitialize configuration first.

Note , if you have installed fun, make sure the version of fun is above 2.10.2.

$ fun --version
2.10.1

quick start

initialization

Use the fun init command to quickly initialize this template project locally.

fun init vangie/selenium-java-example

Install dependencies

$ fun install
...

local test

The content of the test code ChromeDemo is:

public class ChromeDemo implements StreamRequestHandler {


    public void handleRequest(InputStream inputStream,
                              OutputStream outputStream,
                              Context context) throws IOException {

        System.setProperty("webdriver.chrome.driver", "/code/chromedriver");

        ChromeOptions options = new ChromeOptions();
        options.setBinary("/code/headless-chromium");
        options.addArguments("--disable-extensions"); // disabling extensions
        options.addArguments("--disable-gpu"); // applicable to windows os only
        options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
        options.addArguments("--no-sandbox"); // Bypass OS security model
        options.addArguments("--headless");

        WebDriver driver = new ChromeDriver(options);

        driver.get("https://ide.fc.aliyun.com");

        outputStream.write(("Page title is: " + driver.getTitle() + "\n").getBytes());

        driver.quit();

    }

}

run locally

$ mvn package && fun local invoke selenium
...
FC Invoke Start RequestId: 68c83b4c-b053-479c-9b0e-9503582ccb56
handle user request is com.aliyun.fc.selenium.ChromeDemo::handleRequest
cache is null!
Starting ChromeDriver 2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881) on port 20652
Only local connections are allowed.
Mar 05, 2019 11:34:27 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Page title is: 云端集成开发环境
FC Invoke End RequestId: 68c83b4c-b053-479c-9b0e-9503582ccb56


RequestId: 68c83b4c-b053-479c-9b0e-9503582ccb56          Billed Duration: 5265 ms        Memory Size: 1998 MB    Max Memory Used: 240 MB

deploy

$ mvn package && fun deploy

implement

$  fcli function invoke -s chrome -f selenium
  Page title is: 云端集成开发环境

About file size

Since the compressed volume of chromedriver and headless-chromium is very close to 50MB, there is very little space left for the user's Jar, so a high compression ratio version is also made, which is compressed using the brotli algorithm with a higher compression ratio, and the compressed size is 32.7 MB. Then use the initializer to decompress at runtime, and the decompression takes about 3.7 S. https://github.com/vangie/packed-selenium-java-example

reference reading

  1. https://github.com/smithclay/lambdium
  2. https://medium.com/clog/running-selenium-and-headless-chrome-on-aws-lambda-fb350458e4df

join us

team introduction

Alibaba Cloud Function Service is a brand-new computing service that supports the event-driven programming model. It helps users focus on their own business logic, build applications in a serverless manner, and quickly implement low-cost, scalable, and high-availability systems without considering the management of underlying infrastructure such as servers. Users can quickly create prototypes, and the same architecture can scale smoothly with business scale. Make computing more efficient, economical, resilient, and reliable. Both small startups and large corporations benefit from it. Our team is rapidly expanding and we are looking for talent. We're looking for teammates who have solid fundamentals. Not only can you read papers to track industry trends, but you can also quickly code to solve practical problems. Rigorous, systematic thinking skills. It can not only consider business opportunities, system architecture, operation and maintenance costs and many other factors as a whole, but also control the complete process of design/development/testing/release, predict and control risks. Driven by curiosity and a sense of purpose. Happy to explore the unknown, not only a dreamer, but also a practitioner. Tenacity, optimism and confidence. Seeing opportunities amid pressure and difficulty makes work fun! If you are passionate about cloud computing and want to build an influential computing platform and ecosystem, please join us and realize your dreams with us!

description of job

Build a next-generation serverless computing platform, including:

  1. Design and implement a complete and scalable front-end system, including authentication/authority management, metadata management, traffic control, metering and billing, log monitoring, and more
  2. Design and implement flexible and reliable back-end systems, including resource scheduling, load balancing, fault-tolerant processing, etc.
  3. Rich and easy-to-use SDK/Tools/CLI/console
  4. Driven by user needs, track industry trends, and use technology to drive business growth

Job Requirements

  1. Solid basic knowledge of algorithms/data structures/operating systems, excellent logical thinking ability.
  2. Master at least one programming language. For example Java/Go/C/C#/C++.
  3. Experience in developing large-scale, high-availability distributed systems is preferred.
  4. Experience in Web/Mobile Backends/Microservice development is preferred.
  5. Good communication skills and teamwork spirit, with certain organizational and coordination skills.
  6. Bachelor degree or above
  7. More than 3 years of work experience, students who have passed the "Alibaba Coding Standards" certification are preferred, and the certification address: https://edu.aliyun.com/certification/cldt02

CV submission

yixian.dw AT alibaba-inc.com

" Alibaba's cloud-native technology circle focuses on microservices, serverless, containers, service mesh and other technical fields, focuses on cloud-native popular technology trends, and cloud-native large-scale implementation practices, and is a technology circle that understands cloud-native developers best."

{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324124268&siteId=291194637