Building	High	Performance
Search	Feature
Mobile	Development	Stage
Tech	in	Asia	Product	Development	Conference	2017
August	10th,	2017
Who	am	I?
• Setyo	Legowo (@setyolegowo)
• Currently	work	as	Software	Engineer	in	Urbanindo
• Informatics	graduate	from	Institut Teknologi Bandung	(ITB)
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Outline
• Why	search	feature	matter
• All	about	application	performance
• Performance	testing
• Tips	for	optimizations
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Product Name
Key / Terms Driver
List of ProductRelevance sites Closest driver
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Input
Search result
Challenges
• Use-cases	variation
• Bugs
• Mission	critical	feature
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
“3”	Performance	Indicators
Memory
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Processor
I/O
o Load	search	result	and	
assets	to	memory
o Caching
o Compression
o Query
o Context
o Render	assets
o CPU	utilization
o Concurrency
Relevance
o Server	response	time
o Data	usage
o Offline
Lazy	Load
• Load	or	render	what	needed	to	be	appeared	on	the	screen
• Mostly	delay	loading	on	assets
image;	paging	search	result	(occasionally)
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Cache	(Client)
• Save	assets	into	app	local	storage,
but	do	not	save	all	of	it
• Very	useful	when	offline
• “Garbage	collection”	strategy
• Reuse	high	frequency	loaded	assets
• Specific	cache	strategy	which	parallel	with	business
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Cache	(Server)
• Use	Content	Delivery	Network	(CDN)
• Low	bandwidth	and/or	CPU	usage	to	server
• Cache	high	frequency	query	and	its	result	set
• Cache	must	be	faster	than	database
• Easy	to	maintain	if	the	cache	database	complement	with	use	case
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Concurrency
• Process/render	in	“parallel”
• Pool	the	process	or	the	threads
• Better	if	use	throttling	or	queue	mechanism
• Think	the	process	in	Directed	Acyclic	Graph
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Source:	https://upload.wikimedia.org/wikipedia/commons/thumb/4/4b/Directed_acyclic_graph.svg/800px-Directed_acyclic_graph.svg.png
Compression
• Compress	assets	as	much	as	you	can
• Minimize	storage	space	usage
• Reduce	data	transfer	cost
• Use	binary	data	transfer instead	of	alphabet	base
• Disadvantages:	use	more	CPU
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Search	Result	Relevance
• Use	query	language
• Prone	to	ambiguous
• Advance:	Use	text	similarity	algorithm
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
There	are	any	drawbacks?
• Architecture	tend	to	be	more	complex
• Optimization	tends	to	make	code	harder	to	understand	and	
maintain
• Over	focus	on	insignificant	performance	improvement
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Performance	Testing
• Define	the	metrics	(e.g.	SLA)	and	obey	to	it
• Application	profiling
• Find	bottleneck	or	hotspot
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Tips	for	Optimization	(in	general)
• Find	the	bottleneck/hotspot	as	early	as	possible
• Follow	80/20	rules
• Define	metrics
• Number	of	search,	unique	search,	result,	…
• Measure	the	right	load	between	memory,	CPU,	and	I/O
• Clean	code
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Tips	for	Optimization	(search	feature)
• Progressive	update
• Render	search	result	eagerly	“only”	the	appeared	content	or	panel
• Cache	as	much	as	possible
• Able	to	run	in	offline	mode
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Any	question?
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage
Thank	You
Tech	in	Asia	- PDC17,	Mobile	Dev	Stage

"Building High Performance Search Feature" by Setyo Legowo (UrbanIndo)