Share
Embed
Transcript
55 slides
-
2022-09-23 フェアリーデバイセズ株式会社 Fairy Devices Inc. 1 Rust.Tokyo 2022 スポンサーセッション
フェアリーデバイセズがRustを 採用して3年が過ぎました -
About me • Twitter/GitHub: @emergent • Since 2018.9 ◦ Manager
of Product Development Dept. • Publication ◦ 『実践Rustプログラミング入門』共著 ◦ WEB+DB PRESS No.129 (interview) ◦ WEB+DB PRESS No.131 (plan) ◦ 技術書典『機械学習の炊いたん』 2 Satoshi Yoshikawa / 吉川哲史 -
Products @2018-2019 Audio libraries written in C++ WebSocket server in
C++ and the others in Python and TypeScript 7 Tumbler -
Difficulties with services handling audio • Theoretical and implementation difficulties
of audio signal processing, speech recognition, etc. • Difficulties in APIs as a pathway for audio data 8 -
Difficulties with services handling audio • Theoretical and implementation difficulties
of audio signal processing, speech recognition, etc. • Difficulties in APIs as a pathway for audio data 9 Asynchronous communication of audio stream -
Handling audio streams 10 audio application speech recognition Audio stream
Client Server Text -
Handling audio streams 11 audio application speech recognition Audio stream
Client Server Text Asynchronous -
Products @2018-2019 Audio libraries written in C++ WebSocket server in
C++ and the others in Python and TypeScript 12 Tumbler -
Hard to maintain with C++... 13 Write once in C++,
run forever. PIEN CEO / CTO Masato Fujino ※He didn’t say so, (actually). -
Is there the alternative of C++? • Want to increase
software quality ◦ No more segmentation fault • but not at the expense of performance 14 -
Road to use Rust to our products 1. Write codes
in Rust 2. Write codes in Rust 3. Write codes in Rust 4. Say “Rust is good!” to collegues 5. Say “Rust is good!” to CEO 6. Say “Rust is good!” to CEO 7. Say “Rust is good!” to CEO 8. Write codes in Rust 9. Write codes in Rust 10. Write codes in Rust 16 -
Steps with Rust 17 Small start (microservice) Replacement New product
Challenges ・HTTP server ・Connecting Redis Challenges ・WebSocket server ・Connection control Challenges ・HTTP server ・WebSocket API ・RDBMS ・Lambda function ・Layered architecture -
Products with Rust 2019 2020 2021 2022 CATS Backend microservice
(small start) Nyaprus Speech Recognition API (replacement) LINKLET (new product) Product development Personal activity WEB+DB PRESS No.131 Publish Interviewed 18 …and many trivial works in Rust Publish(plan) -
Products with Rust 2019 2020 2021 2022 CATS Backend microservice
(small start) Nyaprus Speech Recognition API (replacement) LINKLET (new product) Product development Personal activity WEB+DB PRESS No.131 Publish Interviewed 19 …and many trivial works in Rust Publish(plan) -
CATS Purpose : to throttle simultaneous connections of APIs •
Concurrent Access Throttling System • A simple HTTP server with Redis backend 20 Application using Actix web Cloud Memorystore (on GCP) HTTP request HTTP response ≒ Redis -
Architecture 21 CATS API server 1 API server 2 API
server 3 Engine 1 Engine 2 Engine i … … Frontend Backend (speech recognition) CATS -
Good points • Operates stably than we thought • High
performance and high load capacity • …And is contributing our business! 23 CATS -
Side stories • Actix Web: soon to be version 1.0
or not? • Participated in Rust communities and gatherings. ◦ “Is anyone familiar with Future anywhere?” 25 CATS -
Products with Rust 2019 2020 2021 2022 CATS Backend microservice
(small start) Nyaprus Speech Recognition API (replacement) LINKLET (new product) Product development Personal activity WEB+DB PRESS No.131 Publish Interviewed 26 …and many trivial works in Rust Publish(plan) -
Nyaprus - Speech Recognition API Purpose: add functionality to speech
recognition API • A frontend server of speech recognition engine • Has WebSocket API • Using warp 27 I want to use tokio-tungstenite -
• Replaced from C++ and Java • Implemented ◦ a
WebSocket server ◦ a proxy server having connection pool Implementation 28 Nyaprus Before After WS server in C++ SR frontend in Java (proprietary) SR engine (proprietary) WS server in Rust Proxy server in Rust SR engine (proprietary) WS: WebSocket SR: Speech Recognition -
Techniques on Rust • trait Stream / Sink ( on
WebSocket server ) • Connection Pooling ( on proxy server ) 29 -
Stream / Sink 30 Nyaprus Client Nyaprus Speech Recognition Engine
rx tx sink stream -
Stream / Sink 32 Nyaprus …and join Client Nyaprus Speech
Recognition Engine rx tx sink stream -
Connection pooling Problem Recognition speed decreases when disconnected due to
cache discard in the speech recognition engine Solution Keep and reuse connections in connection pools 33 Nyaprus -
Good points • First replacement 🎉 • To improve development
productivity ◦ Used task runner (cargo-make) ◦ Used container (Docker, CI/CD) ◦ Created testing tool (in Rust) 37 Nyaprus -
Side stories • Cache problems were discovered just before release
◦ Prototype implemented in 1 day ◦ After 2 weeks of testing & brushing up ◦ Managed to release it! 🎉 38 Nyaprus -
Products with Rust 2019 2020 2021 2022 CATS Backend microservice
(small start) Nyaprus Speech Recognition API (replacement) LINKLET (new product) Product development Personal activity WEB+DB PRESS No.131 Publish Interviewed 39 …and many trivial works in Rust Publish(plan) -
Challenges • “Web service” development (for me) • Developed by
team with multiple people • Continuous development and release 43 LINKLET -
Architecture (part) 44 api-server Web Frontend notification zoom auth0 tlpf-connector
mqtt-connector db-connector Auth0 Zoom Device Controller RDBMS httpclient WebSocket notificaiton HTTP(S) Webhook (HTTP(S)) cipher LINKLET -
Challenges • Asynchronous communication with LINKLET devices ◦ Taking care
of the state of devices ▪ Power ON / OFF ▪ Online / Offline ◦ Non-blocking API ▪ HTTP and WebSocket (push) 46 LINKLET -
Challenges (with Rust) • Wrestling with Diesel (and SQL) •
Layered architecture (in progress) ◦ Using mock (mockall crate) • AWS Lambda function in Rust 47 LINKLET -
Advantages in Rust • Refactoring with peace of mind😌 ◦
by ▪ Compilation errors are well attended ▪ Interfaces are well typed 48 LINKLET -
Steps with Rust 49 Small start (microservice) Replacement New product
Challenges ・HTTP server ・Connecting Redis Challenges ・WebSocket server ・Connection control Challenges ・HTTP server ・WebSocket API ・RDBMS ・Lambda function ・Layered architecture -
Conclusions • Rust is powerful to create web applications ◦
But still less than 30% of our total products 50 -
Futures • Grow our products more with Rust (and modern
techs) ◦ more reliable ◦ more speedy ◦ higher performance 51 -
We are hiring! • Frontend / Backend developer • Device
Engineer • Product Manager • …and more 52 -
We are hiring! • Frontend / Backend developer • Device
Engineer • Product Manager • …and more 53 Please check the job board out!