guid python

Post on 05-Dec-2014

163 Views

Category:

Documents

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

How to implement GUID With Python

charsyam@naver.com

GUID?

Unique ID

When you need Unique ID?

User ID?

User ID? Service ID?

User ID? Service ID?

Event ID?

Example

A Long Long Time Ago

Mac Address?

Device ID?

So, we need Unique ID!!!

UUID

Universally Unique ID

Universally Unique ID

RFC 4122

550e8400-e20b-41d4-a716-446655440000

16 Octet (128bit)

SHA-1(MAC+Time)

BUT …

BUT … BUT …

BUT … BUT … BUT …

UUID is not good For Some Services

Why?

Too Big

Can’t order by Time

How to get these attributes!!

Research Just Google it.

MongoDB

Instagram

Twitter SnowFlake

MongoDB

12 Bytes BSON Object

MongoDB

Instagram

64 bits

Instagram

Instagram

Logical Shard Physical Shard

Slowflake

64 bits

Snowflake

Snowflake

Zookeeper

Python-Guoid

import guoid guid = guoid.SnowFlake(datacenter_id, worker_id) guid.next()

Python-Guoid

https://github.com/charsyam/python-guoid

Python-Guoid

Not service Just Library

Python-Guoid

How to get Datacenter_id

Worker_id

Thank you!

top related