SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
Common Pitfalls of Functional
Programming and How to Avoid Them:
A Mobile Gaming Platform Case Study
Sep 22, 2013

GREE, Inc.
Yasuaki Takebe

Copyright © GREE, Inc. All Rights Reserved.
Introduction
• Why Functional Programming?
•
•
•

Reliability: Eliminate runtime type error, implicit state, ...
High performance: 20-60 times faster than Perl, PHP, Ruby, ...
Productivity: Powerful and elegant, a vast number of libraries, ...

• However...
•

Memory leak

•
•
•

Data lost
Performance degradation
Crash

Copyright © GREE, Inc. All Rights Reserved.
Contents
• About ourselves
•

What we developed using functional programming

• Examples of pitfalls
• How to avoid them
•
•
•
•

Testing tool
Documentation
Technical review
Education

Copyright © GREE, Inc. All Rights Reserved.
About GREE (1/3)
• Overview of GREE's services
•
•

One of the largest mobile game platforms
37.2M users, 2000 games (as of Jun. 2013)

• Business
•
•
•
•
•
•

Social games
Platform: SNS, 3rd party games
Social media: mail magazine, news
Advertising and ad network
Licensing and merchandising
Venture capital

Copyright © GREE, Inc. All Rights Reserved.
About GREE (2/3)
• Example of GREE's products / services

• Social games
•
•
•

Modern War: War simulation game
Miniature Garden: Wonder Mail and Animal Island: Gardening game
...

• SNS app
Features
- Game portal
- See what friends are
playing
- Share updates, photos and
videos
- Notification from friends
when they like your posts

Copyright © GREE, Inc. All Rights Reserved.
About GREE (3/3)
• Company
•
•

Founded: Dec 7, 2004
Employees: 2582 (group, as of Jun. 2013)

• Common architecture
•
•

Client: Java, Objective-C, JavaScript, Unity/C#, ...
Server: PHP, MySQL, Flare (KVS), ...
•

Develop middleware for ourselves

• Functional programming
•
•

Started: Jun, 2012 (a Haskell project)
Engineers: Haskell: 4, Scala: 6

Copyright © GREE, Inc. All Rights Reserved.
What We Developed Using FP (1/2)
• KVS management system
•
•

Setup / destroy KVS nodes in response to hardware fault / sudden access
spike
Used in a social game app

• Components developed in Haskell
•
•
•

Frontend
Control server
Web admin
server

Copyright © GREE, Inc. All Rights Reserved.
What We Developed Using FP (2/2)
• Image storage gateway
•
•
•

Convert WebDAV to memcached / S3 API
Used in SNS photo uploader
Developed using Warp and http-conduit
Upload

PHP
WebDAV
Image
Storage
Gateway

Download

memcached

S3 API

SNS App
Flare Cluster

Flare

OpenStack Swift Cluster
storage
storage
Swift

storage
storage
Swift

Copyright © GREE, Inc. All Rights Reserved.
Examples of Pitfalls

Copyright © GREE, Inc. All Rights Reserved.
Pitfall 1: Leak by Lazy Evaluation
• Issue: Memory leak

• Cause
•
•

Frontend server keeps a list of active thread IDs in TVar for monitoring
Delete from thread ID list
modifyTVar' requestThreads $ ¥threads -> filter (tid /=) threads

•

But this reduces thread ID list only to WHNF
Copyright © GREE, Inc. All Rights Reserved.
Pitfall 1: Leak by Lazy Evaluation (Cont.)
• How to fix
•
•

Evaluate to normal form (or evaluate filters in this case)
In this case we fixed by evaluating length of threads as follows:
modifyTVar requestThreads $ ¥threads ->
let thread' = filter (tid /=) threads
in seq (length threads') threads'

• Pitfall
•
•

It is easy to mix up write to TVar / MVar with other IO operations, which
evaluate value to normal form
Easy to mix up modityTVar', strict version of modifyTVar, with other IO
operations which evaluate the value to normal form

Copyright © GREE, Inc. All Rights Reserved.
Pitfall 2: Race Condition
• Issue: Data put in a queue (very rarely) lost
• Cause
•
•
•

Queue is implemented using TQueue, which has two TVars of list
Dequeue from TQueue is wrapped by timeout, as readTQueue blocks
forever when no item in queue
Definition of timeout
timeout n f = do
pid <- myThreadId
ex <- fmap Timeout newUnique
handleJust (¥e -> if e == ex then Just () else Nothing)
(¥_ -> return Nothing)
(bracket (forkIO (threadDelay n >> throwTo pid ex))
(killThread)
(¥_ -> fmap Just f))

•
•

timeout invokes another thread which wait n microseconds and an
exception to throws current thread
Exception might be thrown when evaluation of f (IO action wrapped by
timeout) just finished
Copyright © GREE, Inc. All Rights Reserved.
Pitfall 2: Race Condition (Cont.)
• How to fix
•

Do not change state of queue in timeout
readRequest q = do
mRequest <- timeout 10 $ atomically $ do
request <- peekTQueue q
return request
case mRequest of
Just _ -> atomically $ tryReadTQueue q
Nothing -> return Nothing

• Pitfall
•
•

Because timeout is implemented as a higher-order function, it is easy to
compose with IO action without taking care of internal implementation
timeout can be used safely only with IO action which does not change
data, such as accept and connectTo

Copyright © GREE, Inc. All Rights Reserved.
Pitfall 3: Library Misuse
• Issue: Performance degradation

• Cause
•

This program uses http-conduit to connect to backend HTTP servers
periodically for health check
manager <- newManager def
http req manager

•
•

newManager forks thread to repeatedly collect stale connections
To finish this thread, closeManager must be called (from version 1.2.0)
Copyright © GREE, Inc. All Rights Reserved.
Pitfall 3: Library Misuse (Cont.)
• How to fix
•

Call closeManager or use withManager
withManager $ (¥manager -> http req manager)

• Pitfall
•
•

Specification of newManager was changed from 1.2.0
Haskell libraries are often developed very actively

Copyright © GREE, Inc. All Rights Reserved.
How to Avoid Pitfalls

Copyright © GREE, Inc. All Rights Reserved.
How to Avoid Pitfalls
• Overview of recurrence prevention method
Pitfall
Documentation

Requirement
analysis
&
Design

Technical
review

Coding

Unit testing

System
testing

Operation
&
Maintenance

System
testing
tool
Functional Programming Education

Copyright © GREE, Inc. All Rights Reserved.
System Testing Tool (1/4)
• Haskell has great unit testing framework
•

HUnit, QuickCheck

• Unit testing is not enough to find critical bugs
•
•
•

System testing
Stress testing
Aging testing (long-running stress testing)

• test-sandbox
•
•
•

System testing framework
Write system tests using HUnit or QuickCheck
Can be used for network applications and CUI tools

Copyright © GREE, Inc. All Rights Reserved.
System Testing Tool (2/4)
• Example: memcached test (HUnit)
setup = do
-- Register memcached using free TCP port to env
port <- getPort "memcached"
register "memcached" "/usr/bin/memcached" [ "-p", show port ] def
test1 = sandboxTest "Store" $ do
-- Send commant through registered TCP port
output <- sendTo "memcached" "set key 0 0 5¥r¥nvalue¥r¥n" 1
assertEqual "item is stored" "STORED¥r¥n" output
main =
defaultMain
[ sandboxTests "Example" $ do
setup
-- Setup env accessible from all tests
start "memcached"
sandboxTestGroup "All" [ test1, test2, ... ]
]

Copyright © GREE, Inc. All Rights Reserved.
System Testing Tool (3/4)
• Example: memcached test (QuickCheck)
•

For any string s, get(set s) == s

sandboxTest "Get and set" $ quickCheck $ do
-- Take any string
str <- pick arbitrary :: PropertyM Sandbox String

-- Get and set string
_ <- run $ sendTo "memcached"
(printf "set key 0 0 %d¥r¥n%s¥r¥n" (length str) str) 20
output <- run $ sendTo "memcached" "get key¥r¥n" 20
-- Check that we get the same string
assert $ printf "VALUE key 0 %d¥r¥n%s¥r¥nEND¥r¥n" (length str) str
== output

Copyright © GREE, Inc. All Rights Reserved.
System Testing Tool (4/4)
• Applied to
•
•

KVS management system
Flare (KVS written in C++)

• # of tests
•

Frontend server
•
•

•

Control server
•
•

•

49 property tests
103 system tests
45 system tests
5000+ assertions

Flare
•
•

Found many bugs
> 7000 tests

http://hackage.haskell.org/package/test-sandbox

Copyright © GREE, Inc. All Rights Reserved.
Documentation of Pitfalls (1/4)
• Problem report
•
•

Describe details of problem
Linked from bug tracking system

•
•
•
•
•
•

Timeline of issue
Temporary measure
Extent of influence
Detailed cause and how to fix
Recurrence prevention
...

•

Scattered among a lot of other problem reports

• Other FP programmers don't read them

Copyright © GREE, Inc. All Rights Reserved.
Documentation of Pitfalls (2/4)
• Aggregated document
•
•
•

Collect problems caused by functional programming
Summarize cause and how to fix for each item
"Writing Middleware in Haskell"

• Contents
•
•
•
•
•
•

Lazy evaluation and memory leak
Preforking and load balancing
Concurrent programming
Libraries
Profiling and optimization
Test and debug

• Other FP programmers still won't read it

Copyright © GREE, Inc. All Rights Reserved.
Documentation of Pitfalls (3/4)
• Automated check using hlint
•
•

Customize hlint to check pitfall
Put item number of aggregated document in hlint comment

warn "Non-strict TVar [1.1]" = modifyTVar ==> modifyTVar'
warn "Should not use timeout with STM [3.1]" =
timeout x (atomically f) ==> somethingElse
•

Check from Emacs

Copyright © GREE, Inc. All Rights Reserved.
Documentation of Pitfalls (4/4)
• Problems of hlint method
•
•
•

Not all pitfalls can be detected by hlint
High level design issue
Library issue (Ex. Version of http-conduit, hashable)

Copyright © GREE, Inc. All Rights Reserved.
Technical Review
• Established technical review process
•

Check feasibility of new technologies such as functional programming by
managements and other teams

Copyright © GREE, Inc. All Rights Reserved.
Education
• Brown bag FP meeting
•
•
•

Once or twice in a month
Scala and Haskell topics
"Make GREE a better place
through the power of FP"

• Education program for
new graduate
•

Haskell code puzzle from
Project Euler

Copyright © GREE, Inc. All Rights Reserved.
Conclusion
• Functional programming is great
•

We develop some key components of our services using FP

• But there are many pitfalls
•

Lazy evaluation, race condition, library misuse, ...

• We should avoid them
•
•
•
•

Testing tool
Documentation
Technical review
Education

Copyright © GREE, Inc. All Rights Reserved.
Copyright © GREE, Inc. All Rights Reserved.

Weitere ähnliche Inhalte

Was ist angesagt?

JavaOne 2015 Java Mixed-Mode Flame Graphs
JavaOne 2015 Java Mixed-Mode Flame GraphsJavaOne 2015 Java Mixed-Mode Flame Graphs
JavaOne 2015 Java Mixed-Mode Flame GraphsBrendan Gregg
 
Stateless Hypervisors at Scale
Stateless Hypervisors at ScaleStateless Hypervisors at Scale
Stateless Hypervisors at ScaleAntony Messerl
 
USENIX ATC 2017: Visualizing Performance with Flame Graphs
USENIX ATC 2017: Visualizing Performance with Flame GraphsUSENIX ATC 2017: Visualizing Performance with Flame Graphs
USENIX ATC 2017: Visualizing Performance with Flame GraphsBrendan Gregg
 
Introduction to .NET Performance Measurement
Introduction to .NET Performance MeasurementIntroduction to .NET Performance Measurement
Introduction to .NET Performance MeasurementSasha Goldshtein
 
PowerShell for Practical Purple Teaming
PowerShell for Practical Purple TeamingPowerShell for Practical Purple Teaming
PowerShell for Practical Purple TeamingNikhil Mittal
 
Steelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with PythonSteelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with Pythoninfodox
 
Developping drivers on small machines
Developping drivers on small machinesDevelopping drivers on small machines
Developping drivers on small machinesAnne Nicolas
 
Vulnerability desing patterns
Vulnerability desing patternsVulnerability desing patterns
Vulnerability desing patternsPeter Hlavaty
 
Performance Analysis: new tools and concepts from the cloud
Performance Analysis: new tools and concepts from the cloudPerformance Analysis: new tools and concepts from the cloud
Performance Analysis: new tools and concepts from the cloudBrendan Gregg
 
Ice Age melting down: Intel features considered usefull!
Ice Age melting down: Intel features considered usefull!Ice Age melting down: Intel features considered usefull!
Ice Age melting down: Intel features considered usefull!Peter Hlavaty
 
YOW2021 Computing Performance
YOW2021 Computing PerformanceYOW2021 Computing Performance
YOW2021 Computing PerformanceBrendan Gregg
 
Practical Windows Kernel Exploitation
Practical Windows Kernel ExploitationPractical Windows Kernel Exploitation
Practical Windows Kernel ExploitationzeroSteiner
 
Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10Honorary_BoT
 
Towards "write once - run whenever possible" with Safety Critical Java af Ben...
Towards "write once - run whenever possible" with Safety Critical Java af Ben...Towards "write once - run whenever possible" with Safety Critical Java af Ben...
Towards "write once - run whenever possible" with Safety Critical Java af Ben...InfinIT - Innovationsnetværket for it
 
Understanding Android Benchmarks
Understanding Android BenchmarksUnderstanding Android Benchmarks
Understanding Android BenchmarksKoan-Sin Tan
 
Container Performance Analysis
Container Performance AnalysisContainer Performance Analysis
Container Performance AnalysisBrendan Gregg
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringGeorg Schönberger
 
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013Amazon Web Services
 

Was ist angesagt? (20)

Attack on the Core
Attack on the CoreAttack on the Core
Attack on the Core
 
JavaOne 2015 Java Mixed-Mode Flame Graphs
JavaOne 2015 Java Mixed-Mode Flame GraphsJavaOne 2015 Java Mixed-Mode Flame Graphs
JavaOne 2015 Java Mixed-Mode Flame Graphs
 
Stateless Hypervisors at Scale
Stateless Hypervisors at ScaleStateless Hypervisors at Scale
Stateless Hypervisors at Scale
 
USENIX ATC 2017: Visualizing Performance with Flame Graphs
USENIX ATC 2017: Visualizing Performance with Flame GraphsUSENIX ATC 2017: Visualizing Performance with Flame Graphs
USENIX ATC 2017: Visualizing Performance with Flame Graphs
 
Introduction to .NET Performance Measurement
Introduction to .NET Performance MeasurementIntroduction to .NET Performance Measurement
Introduction to .NET Performance Measurement
 
PowerShell for Practical Purple Teaming
PowerShell for Practical Purple TeamingPowerShell for Practical Purple Teaming
PowerShell for Practical Purple Teaming
 
Steelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with PythonSteelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with Python
 
Developping drivers on small machines
Developping drivers on small machinesDevelopping drivers on small machines
Developping drivers on small machines
 
Vulnerability desing patterns
Vulnerability desing patternsVulnerability desing patterns
Vulnerability desing patterns
 
Performance Analysis: new tools and concepts from the cloud
Performance Analysis: new tools and concepts from the cloudPerformance Analysis: new tools and concepts from the cloud
Performance Analysis: new tools and concepts from the cloud
 
Ice Age melting down: Intel features considered usefull!
Ice Age melting down: Intel features considered usefull!Ice Age melting down: Intel features considered usefull!
Ice Age melting down: Intel features considered usefull!
 
YOW2021 Computing Performance
YOW2021 Computing PerformanceYOW2021 Computing Performance
YOW2021 Computing Performance
 
Back to the CORE
Back to the COREBack to the CORE
Back to the CORE
 
Practical Windows Kernel Exploitation
Practical Windows Kernel ExploitationPractical Windows Kernel Exploitation
Practical Windows Kernel Exploitation
 
Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10
 
Towards "write once - run whenever possible" with Safety Critical Java af Ben...
Towards "write once - run whenever possible" with Safety Critical Java af Ben...Towards "write once - run whenever possible" with Safety Critical Java af Ben...
Towards "write once - run whenever possible" with Safety Critical Java af Ben...
 
Understanding Android Benchmarks
Understanding Android BenchmarksUnderstanding Android Benchmarks
Understanding Android Benchmarks
 
Container Performance Analysis
Container Performance AnalysisContainer Performance Analysis
Container Performance Analysis
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and Monitoring
 
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
 

Ähnlich wie Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gaming Platform Case Study

DockerCon Europe 2018 Monitoring & Logging Workshop
DockerCon Europe 2018 Monitoring & Logging WorkshopDockerCon Europe 2018 Monitoring & Logging Workshop
DockerCon Europe 2018 Monitoring & Logging WorkshopBrian Christner
 
Early Software Development through Palladium Emulation
Early Software Development through Palladium EmulationEarly Software Development through Palladium Emulation
Early Software Development through Palladium EmulationRaghav Nayak
 
How to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experienceHow to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experienceDocker, Inc.
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Splunk: Forward me the REST of those shells
Splunk: Forward me the REST of those shellsSplunk: Forward me the REST of those shells
Splunk: Forward me the REST of those shellsAnthony D Hendricks
 
Coverage Solutions on Emulators
Coverage Solutions on EmulatorsCoverage Solutions on Emulators
Coverage Solutions on EmulatorsDVClub
 
HeapStats: Troubleshooting with Serviceability and the New Runtime Monitoring...
HeapStats: Troubleshooting with Serviceability and the New Runtime Monitoring...HeapStats: Troubleshooting with Serviceability and the New Runtime Monitoring...
HeapStats: Troubleshooting with Serviceability and the New Runtime Monitoring...Yuji Kubota
 
Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015Pavel Chunyayev
 
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...Hackito Ergo Sum
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsC4Media
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsGraham Dumpleton
 
Oracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuningOracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuningMichel Schildmeijer
 
Platform Security Summit 18: Xen Security Weather Report 2018
Platform Security Summit 18: Xen Security Weather Report 2018Platform Security Summit 18: Xen Security Weather Report 2018
Platform Security Summit 18: Xen Security Weather Report 2018The Linux Foundation
 
19-reliabilitytesting.ppt
19-reliabilitytesting.ppt19-reliabilitytesting.ppt
19-reliabilitytesting.pptAnilteaser
 
Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...
Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...
Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...rschuppe
 
Open source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packagesOpen source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packagesRogue Wave Software
 
Realtime traffic analyser
Realtime traffic analyserRealtime traffic analyser
Realtime traffic analyserAlex Moskvin
 
Mock cli with Python unittest
Mock cli with Python unittestMock cli with Python unittest
Mock cli with Python unittestSong Jin
 

Ähnlich wie Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gaming Platform Case Study (20)

DockerCon Europe 2018 Monitoring & Logging Workshop
DockerCon Europe 2018 Monitoring & Logging WorkshopDockerCon Europe 2018 Monitoring & Logging Workshop
DockerCon Europe 2018 Monitoring & Logging Workshop
 
Early Software Development through Palladium Emulation
Early Software Development through Palladium EmulationEarly Software Development through Palladium Emulation
Early Software Development through Palladium Emulation
 
How to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experienceHow to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experience
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Splunk: Forward me the REST of those shells
Splunk: Forward me the REST of those shellsSplunk: Forward me the REST of those shells
Splunk: Forward me the REST of those shells
 
Coverage Solutions on Emulators
Coverage Solutions on EmulatorsCoverage Solutions on Emulators
Coverage Solutions on Emulators
 
HeapStats: Troubleshooting with Serviceability and the New Runtime Monitoring...
HeapStats: Troubleshooting with Serviceability and the New Runtime Monitoring...HeapStats: Troubleshooting with Serviceability and the New Runtime Monitoring...
HeapStats: Troubleshooting with Serviceability and the New Runtime Monitoring...
 
Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015
 
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Fastest Servlets in the West
Fastest Servlets in the WestFastest Servlets in the West
Fastest Servlets in the West
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
Oracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuningOracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuning
 
Next-gen Automation Framework
Next-gen Automation FrameworkNext-gen Automation Framework
Next-gen Automation Framework
 
Platform Security Summit 18: Xen Security Weather Report 2018
Platform Security Summit 18: Xen Security Weather Report 2018Platform Security Summit 18: Xen Security Weather Report 2018
Platform Security Summit 18: Xen Security Weather Report 2018
 
19-reliabilitytesting.ppt
19-reliabilitytesting.ppt19-reliabilitytesting.ppt
19-reliabilitytesting.ppt
 
Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...
Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...
Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...
 
Open source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packagesOpen source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packages
 
Realtime traffic analyser
Realtime traffic analyserRealtime traffic analyser
Realtime traffic analyser
 
Mock cli with Python unittest
Mock cli with Python unittestMock cli with Python unittest
Mock cli with Python unittest
 

Mehr von gree_tech

アナザーエデンPC版リリースへの道のり 〜WFSにおけるマルチプラットフォーム対応の取り組み〜
アナザーエデンPC版リリースへの道のり 〜WFSにおけるマルチプラットフォーム対応の取り組み〜アナザーエデンPC版リリースへの道のり 〜WFSにおけるマルチプラットフォーム対応の取り組み〜
アナザーエデンPC版リリースへの道のり 〜WFSにおけるマルチプラットフォーム対応の取り組み〜gree_tech
 
GREE VR Studio Laboratory「XR-UX Devプロジェクト」の成果紹介
GREE VR Studio Laboratory「XR-UX Devプロジェクト」の成果紹介GREE VR Studio Laboratory「XR-UX Devプロジェクト」の成果紹介
GREE VR Studio Laboratory「XR-UX Devプロジェクト」の成果紹介gree_tech
 
REALITYアバターを様々なメタバースで活躍させてみた - GREE VR Studio Laboratory インターン研究成果発表
REALITYアバターを様々なメタバースで活躍させてみた - GREE VR Studio Laboratory インターン研究成果発表REALITYアバターを様々なメタバースで活躍させてみた - GREE VR Studio Laboratory インターン研究成果発表
REALITYアバターを様々なメタバースで活躍させてみた - GREE VR Studio Laboratory インターン研究成果発表gree_tech
 
アプリ起動時間高速化 ~推測するな、計測せよ~
アプリ起動時間高速化 ~推測するな、計測せよ~アプリ起動時間高速化 ~推測するな、計測せよ~
アプリ起動時間高速化 ~推測するな、計測せよ~gree_tech
 
長寿なゲーム事業におけるアプリビルドの効率化
長寿なゲーム事業におけるアプリビルドの効率化長寿なゲーム事業におけるアプリビルドの効率化
長寿なゲーム事業におけるアプリビルドの効率化gree_tech
 
Cloud Spanner をより便利にする運用支援ツールの紹介
Cloud Spanner をより便利にする運用支援ツールの紹介Cloud Spanner をより便利にする運用支援ツールの紹介
Cloud Spanner をより便利にする運用支援ツールの紹介gree_tech
 
WFSにおけるCloud SpannerとGKEを中心としたGCP導入事例の紹介
WFSにおけるCloud SpannerとGKEを中心としたGCP導入事例の紹介WFSにおけるCloud SpannerとGKEを中心としたGCP導入事例の紹介
WFSにおけるCloud SpannerとGKEを中心としたGCP導入事例の紹介gree_tech
 
SINoALICE -シノアリス- Google Cloud Firestoreを用いた観戦機能の実現について
SINoALICE -シノアリス- Google Cloud Firestoreを用いた観戦機能の実現についてSINoALICE -シノアリス- Google Cloud Firestoreを用いた観戦機能の実現について
SINoALICE -シノアリス- Google Cloud Firestoreを用いた観戦機能の実現についてgree_tech
 
海外展開と負荷試験
海外展開と負荷試験海外展開と負荷試験
海外展開と負荷試験gree_tech
 
翻訳QAでのテスト自動化の取り組み
翻訳QAでのテスト自動化の取り組み翻訳QAでのテスト自動化の取り組み
翻訳QAでのテスト自動化の取り組みgree_tech
 
組み込み開発のテストとゲーム開発のテストの違い
組み込み開発のテストとゲーム開発のテストの違い組み込み開発のテストとゲーム開発のテストの違い
組み込み開発のテストとゲーム開発のテストの違いgree_tech
 
サーバーフレームワークに潜んでる脆弱性検知ツール紹介
サーバーフレームワークに潜んでる脆弱性検知ツール紹介サーバーフレームワークに潜んでる脆弱性検知ツール紹介
サーバーフレームワークに潜んでる脆弱性検知ツール紹介gree_tech
 
データエンジニアとアナリストチーム兼務になった件について
データエンジニアとアナリストチーム兼務になった件についてデータエンジニアとアナリストチーム兼務になった件について
データエンジニアとアナリストチーム兼務になった件についてgree_tech
 
シェアドサービスとしてのデータテクノロジー
シェアドサービスとしてのデータテクノロジーシェアドサービスとしてのデータテクノロジー
シェアドサービスとしてのデータテクノロジーgree_tech
 
「ドキュメント見つからない問題」をなんとかしたい - 横断検索エンジン導入の取り組みについて-
「ドキュメント見つからない問題」をなんとかしたい - 横断検索エンジン導入の取り組みについて-「ドキュメント見つからない問題」をなんとかしたい - 横断検索エンジン導入の取り組みについて-
「ドキュメント見つからない問題」をなんとかしたい - 横断検索エンジン導入の取り組みについて-gree_tech
 
「Atomic Design × Nuxt.js」コンポーネント毎に責務の範囲を明確にしたら幸せになった話
「Atomic Design × Nuxt.js」コンポーネント毎に責務の範囲を明確にしたら幸せになった話「Atomic Design × Nuxt.js」コンポーネント毎に責務の範囲を明確にしたら幸せになった話
「Atomic Design × Nuxt.js」コンポーネント毎に責務の範囲を明確にしたら幸せになった話gree_tech
 
比較サイトの検索改善(SPA から SSR に変換)
比較サイトの検索改善(SPA から SSR に変換)比較サイトの検索改善(SPA から SSR に変換)
比較サイトの検索改善(SPA から SSR に変換)gree_tech
 
コードの自動修正によって実現する、機能開発を止めないフレームワーク移行
コードの自動修正によって実現する、機能開発を止めないフレームワーク移行コードの自動修正によって実現する、機能開発を止めないフレームワーク移行
コードの自動修正によって実現する、機能開発を止めないフレームワーク移行gree_tech
 
「やんちゃ、足りてる?」〜ヤンマガWebで挑戦を続ける新入りエンジニア〜
「やんちゃ、足りてる?」〜ヤンマガWebで挑戦を続ける新入りエンジニア〜「やんちゃ、足りてる?」〜ヤンマガWebで挑戦を続ける新入りエンジニア〜
「やんちゃ、足りてる?」〜ヤンマガWebで挑戦を続ける新入りエンジニア〜gree_tech
 
法人向けメタバースプラットフォームの開発の裏側をのぞいてみた(仮)
法人向けメタバースプラットフォームの開発の裏側をのぞいてみた(仮)法人向けメタバースプラットフォームの開発の裏側をのぞいてみた(仮)
法人向けメタバースプラットフォームの開発の裏側をのぞいてみた(仮)gree_tech
 

Mehr von gree_tech (20)

アナザーエデンPC版リリースへの道のり 〜WFSにおけるマルチプラットフォーム対応の取り組み〜
アナザーエデンPC版リリースへの道のり 〜WFSにおけるマルチプラットフォーム対応の取り組み〜アナザーエデンPC版リリースへの道のり 〜WFSにおけるマルチプラットフォーム対応の取り組み〜
アナザーエデンPC版リリースへの道のり 〜WFSにおけるマルチプラットフォーム対応の取り組み〜
 
GREE VR Studio Laboratory「XR-UX Devプロジェクト」の成果紹介
GREE VR Studio Laboratory「XR-UX Devプロジェクト」の成果紹介GREE VR Studio Laboratory「XR-UX Devプロジェクト」の成果紹介
GREE VR Studio Laboratory「XR-UX Devプロジェクト」の成果紹介
 
REALITYアバターを様々なメタバースで活躍させてみた - GREE VR Studio Laboratory インターン研究成果発表
REALITYアバターを様々なメタバースで活躍させてみた - GREE VR Studio Laboratory インターン研究成果発表REALITYアバターを様々なメタバースで活躍させてみた - GREE VR Studio Laboratory インターン研究成果発表
REALITYアバターを様々なメタバースで活躍させてみた - GREE VR Studio Laboratory インターン研究成果発表
 
アプリ起動時間高速化 ~推測するな、計測せよ~
アプリ起動時間高速化 ~推測するな、計測せよ~アプリ起動時間高速化 ~推測するな、計測せよ~
アプリ起動時間高速化 ~推測するな、計測せよ~
 
長寿なゲーム事業におけるアプリビルドの効率化
長寿なゲーム事業におけるアプリビルドの効率化長寿なゲーム事業におけるアプリビルドの効率化
長寿なゲーム事業におけるアプリビルドの効率化
 
Cloud Spanner をより便利にする運用支援ツールの紹介
Cloud Spanner をより便利にする運用支援ツールの紹介Cloud Spanner をより便利にする運用支援ツールの紹介
Cloud Spanner をより便利にする運用支援ツールの紹介
 
WFSにおけるCloud SpannerとGKEを中心としたGCP導入事例の紹介
WFSにおけるCloud SpannerとGKEを中心としたGCP導入事例の紹介WFSにおけるCloud SpannerとGKEを中心としたGCP導入事例の紹介
WFSにおけるCloud SpannerとGKEを中心としたGCP導入事例の紹介
 
SINoALICE -シノアリス- Google Cloud Firestoreを用いた観戦機能の実現について
SINoALICE -シノアリス- Google Cloud Firestoreを用いた観戦機能の実現についてSINoALICE -シノアリス- Google Cloud Firestoreを用いた観戦機能の実現について
SINoALICE -シノアリス- Google Cloud Firestoreを用いた観戦機能の実現について
 
海外展開と負荷試験
海外展開と負荷試験海外展開と負荷試験
海外展開と負荷試験
 
翻訳QAでのテスト自動化の取り組み
翻訳QAでのテスト自動化の取り組み翻訳QAでのテスト自動化の取り組み
翻訳QAでのテスト自動化の取り組み
 
組み込み開発のテストとゲーム開発のテストの違い
組み込み開発のテストとゲーム開発のテストの違い組み込み開発のテストとゲーム開発のテストの違い
組み込み開発のテストとゲーム開発のテストの違い
 
サーバーフレームワークに潜んでる脆弱性検知ツール紹介
サーバーフレームワークに潜んでる脆弱性検知ツール紹介サーバーフレームワークに潜んでる脆弱性検知ツール紹介
サーバーフレームワークに潜んでる脆弱性検知ツール紹介
 
データエンジニアとアナリストチーム兼務になった件について
データエンジニアとアナリストチーム兼務になった件についてデータエンジニアとアナリストチーム兼務になった件について
データエンジニアとアナリストチーム兼務になった件について
 
シェアドサービスとしてのデータテクノロジー
シェアドサービスとしてのデータテクノロジーシェアドサービスとしてのデータテクノロジー
シェアドサービスとしてのデータテクノロジー
 
「ドキュメント見つからない問題」をなんとかしたい - 横断検索エンジン導入の取り組みについて-
「ドキュメント見つからない問題」をなんとかしたい - 横断検索エンジン導入の取り組みについて-「ドキュメント見つからない問題」をなんとかしたい - 横断検索エンジン導入の取り組みについて-
「ドキュメント見つからない問題」をなんとかしたい - 横断検索エンジン導入の取り組みについて-
 
「Atomic Design × Nuxt.js」コンポーネント毎に責務の範囲を明確にしたら幸せになった話
「Atomic Design × Nuxt.js」コンポーネント毎に責務の範囲を明確にしたら幸せになった話「Atomic Design × Nuxt.js」コンポーネント毎に責務の範囲を明確にしたら幸せになった話
「Atomic Design × Nuxt.js」コンポーネント毎に責務の範囲を明確にしたら幸せになった話
 
比較サイトの検索改善(SPA から SSR に変換)
比較サイトの検索改善(SPA から SSR に変換)比較サイトの検索改善(SPA から SSR に変換)
比較サイトの検索改善(SPA から SSR に変換)
 
コードの自動修正によって実現する、機能開発を止めないフレームワーク移行
コードの自動修正によって実現する、機能開発を止めないフレームワーク移行コードの自動修正によって実現する、機能開発を止めないフレームワーク移行
コードの自動修正によって実現する、機能開発を止めないフレームワーク移行
 
「やんちゃ、足りてる?」〜ヤンマガWebで挑戦を続ける新入りエンジニア〜
「やんちゃ、足りてる?」〜ヤンマガWebで挑戦を続ける新入りエンジニア〜「やんちゃ、足りてる?」〜ヤンマガWebで挑戦を続ける新入りエンジニア〜
「やんちゃ、足りてる?」〜ヤンマガWebで挑戦を続ける新入りエンジニア〜
 
法人向けメタバースプラットフォームの開発の裏側をのぞいてみた(仮)
法人向けメタバースプラットフォームの開発の裏側をのぞいてみた(仮)法人向けメタバースプラットフォームの開発の裏側をのぞいてみた(仮)
法人向けメタバースプラットフォームの開発の裏側をのぞいてみた(仮)
 

Kürzlich hochgeladen

NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 

Kürzlich hochgeladen (20)

NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 

Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gaming Platform Case Study

  • 1. Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gaming Platform Case Study Sep 22, 2013 GREE, Inc. Yasuaki Takebe Copyright © GREE, Inc. All Rights Reserved.
  • 2. Introduction • Why Functional Programming? • • • Reliability: Eliminate runtime type error, implicit state, ... High performance: 20-60 times faster than Perl, PHP, Ruby, ... Productivity: Powerful and elegant, a vast number of libraries, ... • However... • Memory leak • • • Data lost Performance degradation Crash Copyright © GREE, Inc. All Rights Reserved.
  • 3. Contents • About ourselves • What we developed using functional programming • Examples of pitfalls • How to avoid them • • • • Testing tool Documentation Technical review Education Copyright © GREE, Inc. All Rights Reserved.
  • 4. About GREE (1/3) • Overview of GREE's services • • One of the largest mobile game platforms 37.2M users, 2000 games (as of Jun. 2013) • Business • • • • • • Social games Platform: SNS, 3rd party games Social media: mail magazine, news Advertising and ad network Licensing and merchandising Venture capital Copyright © GREE, Inc. All Rights Reserved.
  • 5. About GREE (2/3) • Example of GREE's products / services • Social games • • • Modern War: War simulation game Miniature Garden: Wonder Mail and Animal Island: Gardening game ... • SNS app Features - Game portal - See what friends are playing - Share updates, photos and videos - Notification from friends when they like your posts Copyright © GREE, Inc. All Rights Reserved.
  • 6. About GREE (3/3) • Company • • Founded: Dec 7, 2004 Employees: 2582 (group, as of Jun. 2013) • Common architecture • • Client: Java, Objective-C, JavaScript, Unity/C#, ... Server: PHP, MySQL, Flare (KVS), ... • Develop middleware for ourselves • Functional programming • • Started: Jun, 2012 (a Haskell project) Engineers: Haskell: 4, Scala: 6 Copyright © GREE, Inc. All Rights Reserved.
  • 7. What We Developed Using FP (1/2) • KVS management system • • Setup / destroy KVS nodes in response to hardware fault / sudden access spike Used in a social game app • Components developed in Haskell • • • Frontend Control server Web admin server Copyright © GREE, Inc. All Rights Reserved.
  • 8. What We Developed Using FP (2/2) • Image storage gateway • • • Convert WebDAV to memcached / S3 API Used in SNS photo uploader Developed using Warp and http-conduit Upload PHP WebDAV Image Storage Gateway Download memcached S3 API SNS App Flare Cluster Flare OpenStack Swift Cluster storage storage Swift storage storage Swift Copyright © GREE, Inc. All Rights Reserved.
  • 9. Examples of Pitfalls Copyright © GREE, Inc. All Rights Reserved.
  • 10. Pitfall 1: Leak by Lazy Evaluation • Issue: Memory leak • Cause • • Frontend server keeps a list of active thread IDs in TVar for monitoring Delete from thread ID list modifyTVar' requestThreads $ ¥threads -> filter (tid /=) threads • But this reduces thread ID list only to WHNF Copyright © GREE, Inc. All Rights Reserved.
  • 11. Pitfall 1: Leak by Lazy Evaluation (Cont.) • How to fix • • Evaluate to normal form (or evaluate filters in this case) In this case we fixed by evaluating length of threads as follows: modifyTVar requestThreads $ ¥threads -> let thread' = filter (tid /=) threads in seq (length threads') threads' • Pitfall • • It is easy to mix up write to TVar / MVar with other IO operations, which evaluate value to normal form Easy to mix up modityTVar', strict version of modifyTVar, with other IO operations which evaluate the value to normal form Copyright © GREE, Inc. All Rights Reserved.
  • 12. Pitfall 2: Race Condition • Issue: Data put in a queue (very rarely) lost • Cause • • • Queue is implemented using TQueue, which has two TVars of list Dequeue from TQueue is wrapped by timeout, as readTQueue blocks forever when no item in queue Definition of timeout timeout n f = do pid <- myThreadId ex <- fmap Timeout newUnique handleJust (¥e -> if e == ex then Just () else Nothing) (¥_ -> return Nothing) (bracket (forkIO (threadDelay n >> throwTo pid ex)) (killThread) (¥_ -> fmap Just f)) • • timeout invokes another thread which wait n microseconds and an exception to throws current thread Exception might be thrown when evaluation of f (IO action wrapped by timeout) just finished Copyright © GREE, Inc. All Rights Reserved.
  • 13. Pitfall 2: Race Condition (Cont.) • How to fix • Do not change state of queue in timeout readRequest q = do mRequest <- timeout 10 $ atomically $ do request <- peekTQueue q return request case mRequest of Just _ -> atomically $ tryReadTQueue q Nothing -> return Nothing • Pitfall • • Because timeout is implemented as a higher-order function, it is easy to compose with IO action without taking care of internal implementation timeout can be used safely only with IO action which does not change data, such as accept and connectTo Copyright © GREE, Inc. All Rights Reserved.
  • 14. Pitfall 3: Library Misuse • Issue: Performance degradation • Cause • This program uses http-conduit to connect to backend HTTP servers periodically for health check manager <- newManager def http req manager • • newManager forks thread to repeatedly collect stale connections To finish this thread, closeManager must be called (from version 1.2.0) Copyright © GREE, Inc. All Rights Reserved.
  • 15. Pitfall 3: Library Misuse (Cont.) • How to fix • Call closeManager or use withManager withManager $ (¥manager -> http req manager) • Pitfall • • Specification of newManager was changed from 1.2.0 Haskell libraries are often developed very actively Copyright © GREE, Inc. All Rights Reserved.
  • 16. How to Avoid Pitfalls Copyright © GREE, Inc. All Rights Reserved.
  • 17. How to Avoid Pitfalls • Overview of recurrence prevention method Pitfall Documentation Requirement analysis & Design Technical review Coding Unit testing System testing Operation & Maintenance System testing tool Functional Programming Education Copyright © GREE, Inc. All Rights Reserved.
  • 18. System Testing Tool (1/4) • Haskell has great unit testing framework • HUnit, QuickCheck • Unit testing is not enough to find critical bugs • • • System testing Stress testing Aging testing (long-running stress testing) • test-sandbox • • • System testing framework Write system tests using HUnit or QuickCheck Can be used for network applications and CUI tools Copyright © GREE, Inc. All Rights Reserved.
  • 19. System Testing Tool (2/4) • Example: memcached test (HUnit) setup = do -- Register memcached using free TCP port to env port <- getPort "memcached" register "memcached" "/usr/bin/memcached" [ "-p", show port ] def test1 = sandboxTest "Store" $ do -- Send commant through registered TCP port output <- sendTo "memcached" "set key 0 0 5¥r¥nvalue¥r¥n" 1 assertEqual "item is stored" "STORED¥r¥n" output main = defaultMain [ sandboxTests "Example" $ do setup -- Setup env accessible from all tests start "memcached" sandboxTestGroup "All" [ test1, test2, ... ] ] Copyright © GREE, Inc. All Rights Reserved.
  • 20. System Testing Tool (3/4) • Example: memcached test (QuickCheck) • For any string s, get(set s) == s sandboxTest "Get and set" $ quickCheck $ do -- Take any string str <- pick arbitrary :: PropertyM Sandbox String -- Get and set string _ <- run $ sendTo "memcached" (printf "set key 0 0 %d¥r¥n%s¥r¥n" (length str) str) 20 output <- run $ sendTo "memcached" "get key¥r¥n" 20 -- Check that we get the same string assert $ printf "VALUE key 0 %d¥r¥n%s¥r¥nEND¥r¥n" (length str) str == output Copyright © GREE, Inc. All Rights Reserved.
  • 21. System Testing Tool (4/4) • Applied to • • KVS management system Flare (KVS written in C++) • # of tests • Frontend server • • • Control server • • • 49 property tests 103 system tests 45 system tests 5000+ assertions Flare • • Found many bugs > 7000 tests http://hackage.haskell.org/package/test-sandbox Copyright © GREE, Inc. All Rights Reserved.
  • 22. Documentation of Pitfalls (1/4) • Problem report • • Describe details of problem Linked from bug tracking system • • • • • • Timeline of issue Temporary measure Extent of influence Detailed cause and how to fix Recurrence prevention ... • Scattered among a lot of other problem reports • Other FP programmers don't read them Copyright © GREE, Inc. All Rights Reserved.
  • 23. Documentation of Pitfalls (2/4) • Aggregated document • • • Collect problems caused by functional programming Summarize cause and how to fix for each item "Writing Middleware in Haskell" • Contents • • • • • • Lazy evaluation and memory leak Preforking and load balancing Concurrent programming Libraries Profiling and optimization Test and debug • Other FP programmers still won't read it Copyright © GREE, Inc. All Rights Reserved.
  • 24. Documentation of Pitfalls (3/4) • Automated check using hlint • • Customize hlint to check pitfall Put item number of aggregated document in hlint comment warn "Non-strict TVar [1.1]" = modifyTVar ==> modifyTVar' warn "Should not use timeout with STM [3.1]" = timeout x (atomically f) ==> somethingElse • Check from Emacs Copyright © GREE, Inc. All Rights Reserved.
  • 25. Documentation of Pitfalls (4/4) • Problems of hlint method • • • Not all pitfalls can be detected by hlint High level design issue Library issue (Ex. Version of http-conduit, hashable) Copyright © GREE, Inc. All Rights Reserved.
  • 26. Technical Review • Established technical review process • Check feasibility of new technologies such as functional programming by managements and other teams Copyright © GREE, Inc. All Rights Reserved.
  • 27. Education • Brown bag FP meeting • • • Once or twice in a month Scala and Haskell topics "Make GREE a better place through the power of FP" • Education program for new graduate • Haskell code puzzle from Project Euler Copyright © GREE, Inc. All Rights Reserved.
  • 28. Conclusion • Functional programming is great • We develop some key components of our services using FP • But there are many pitfalls • Lazy evaluation, race condition, library misuse, ... • We should avoid them • • • • Testing tool Documentation Technical review Education Copyright © GREE, Inc. All Rights Reserved.
  • 29. Copyright © GREE, Inc. All Rights Reserved.