å é¨WebAPIã®å¼ã³åºãã³ã¹ã - MVCã¢ãã«ã®â次â
ãããµãï¼ï¼ï¼ï¼ã§id:secondlifeæ°ãçºè¡¨ãããã¨ããè³æãè¦ã¦ã¿ã¾ããã
http://www.slideshare.net/hotchpotch/deb2009-1023281
ã¯ã¦ã¶ããã«ã¹ã¯ã©ããã§ãªãã¥ã¼ã¢ã«ããéã«ãå¾æ¥ã®MVCã¢ãã«ããããã«ä¸æ©é²ãã§æ½è±¡åãé²ããã¨ã®ãã¨ã§ã
è³æä¸ãMVCã®çºå±ç³»ã¨ãã¦ãMVACãªãæ¦å¿µãæå±ããã¦ããã®ã§ãããAã¯ãApplicaiontãï¼ï¼ãã¢ããªã±ã¼ã·ã§ã³ã¬ã¤ã¤ã®ä½æãã¨ããè¨è¿°ããããããã¶ãApplicationã®typoã§ãããã£ã¨ã
è³æããã¯ããã¼ã¿ã½ã¼ã¹å±¤ãããµã¼ãã¹å±¤ããã¢ããªã±ã¼ã·ã§ã³å±¤ãã®ï¼å±¤ããModelããViewããApplicationããControllerãã«ã©ã対å¿ããã®ãããããããªãã£ããã©ãããããããµã¼ãã¹å±¤ããæ
å½ããã®ããApplicationããªã®ã§ããã¾ãããã
ããã¦ãããã¼ã¿ã½ã¼ã¹å±¤ãã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ã§ããããµã¼ãã¹å±¤ããWebAPIåããã°ããã¼ã¿ã½ã¼ã¹å±¤ãã¨ãã¢ããªã±ã¼ã·ã§ã³å±¤ãã¯ãç©ççã«å¥ã®ãã·ã³ã§åãããã¨ãã§ããã¯ãããï¼ï¼ç¾ç¶ã©ããªã®ãç¥ãã¾ãããï¼ã
å¾æ¥ã®MVCã¢ãã«ã§ã¯ãããã¼ã¿ã½ã¼ã¹å±¤ããæ
å½ããModelã¨ããã¢ããªã±ã¼ã·ã§ã³å±¤ããæ
å½ããControllerãããªãã£ãããã©ããããã®éã«ããã²ã¨ã¤ããµã¼ãã¹å±¤ãã¨ããã¤ã³ã¿ã¼ãã§ã¼ã¹ããã¾ãã¦ãæ½è±¡åã¬ãã«ãä¸ãã¦ãããããã¦ããã«ããã¼ã¿ã½ã¼ã¹å±¤ãã¨ãã¢ããªã±ã¼ã·ã§ã³å±¤ããå¥ãã·ã³ã§åä½ããããRPCã¹ã¿ã¤ã«ã®è¨è¨ãã大è¦æ¨¡ãµã¤ãã®ã¿ãªããä¸è¦æ¨¡ãµã¤ãã§ãçãããªããªãããããªå¾åããä»å¾é²ãã§ããæ°ããã¾ãã
Lang-8ã¯ã¾ãã«ããã®æ çµã¿ãæ¡ç¨ãã¦ãã¾ããããµã¼ãã¹å±¤ããæ°ãã«ããããããã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ãRESTfulã«WebAPIåãã¦ããã¢ããªã±ã¼ã·ã§ã³å±¤ããæ
ãããã³ãã¨ã³ãã«ãªã½ã¼ã¹ãæä¾ããã£ã¦æãã§ãã
ãããã£ãRPCã¹ã¿ã¤ã«ï¼ããã¼ã¿ã½ã¼ã¹å±¤ãã¨ãã¢ããªã±ã¼ã·ã§ã³å±¤ããå¥ãã·ã³ã§åããï¼ãã¨ãå ´åãã©ãã§ã·ã¹ãã ãåãåããããã¤ã¾ãä¸ã§è¨ãããµã¼ãã¹å±¤ããããã³ãã¨ã³ããããã¯ã¨ã³ãã®ã©ã¡ãå´ã«ãã£ã¦ãããããè¨è¨ã«ããã¦éµã«ãªãããããªããã¨ããªããªãå¥ãã·ã³ã§åä½ãããå ´åãåä¸ãã·ã³ä¸ã§åããå ´åã«æ¯ã¹ã¦ãéä¿¡ã³ã¹ããå§åçã«å¤§ããããã§ããä¾ãã°Lang-8ã®å ´åãããã³ãã¨ã³ããµã¼ããããåä¸ãµããããã«ããããã¯ã¨ã³ããµã¼ãã®APIãã³ã¼ã«ããå ´åãæ¥ç¶ãªã¼ãã¼ãããã ãã§ã1ãªã¯ã¨ã¹ããããå¹³å16msæãã£ã¦ãã¾ãã
Lang-8ã§ã¯ãããµã¼ãã¹å±¤ãã«æ±ãããããªã½ã¼ã¹ã®ç²åº¦ã¨ããã¼ã¿ã½ã¼ã¹å±¤ããæä¾ãããªã½ã¼ã¹ã®ç²åº¦ï¼ããã¯ORMã«ãããããã©å¤§æµDBMSã®ã¬ã³ã¼ãåä½ã«ãªãã§ããããï¼ãæ¯è¼ããçµæãéä¿¡ã³ã¹ããæããããããµã¼ãã¹å±¤ããããã¯ã¨ã³ãå´ã«ãã£ã¦ããã¨ããå¤æããã¾ããã
ä¼¼ã話ã§ããããã¯ã¼ã¯è¶ã(HTTP)ã§RESTã§ãªã½ã¼ã¹ãæä¾ããæ çµã¿ãæä¾ãã¦ããããã®ã§ãAmazonã«ããEC2åã³SimpleDBã¨ããã®ãããã¾ãã
EC2ãµã¼ãã¹ãæä¾ããã¯ã©ã¹ã¿ã¼ã¨SimpleDBãæä¾ããã¯ã©ã¹ã¿ã¼ã¯ãããã¯ã¼ã¯çã«ããªãè¿ãå ´æã«ããã¨ãããåãããã£ãããããããã§ãããhttp://blog.myrss.jp/archives/2008/11/amazon_simpledb.htmlã«ããã°ãEC2ããSimpleDBãå¼ã³åºããå ´åã
https æ¥ç¶ã®ãªã¼ãã¼ãããã ãã測å®ãã¦ã¿ãã¨ã1000ãªã¯ã¨ã¹ãããã 15 ç§
ã¨ã®ãã¨ãã¤ã¾ã1ãªã¯ã¨ã¹ãããã15msãLang-8ã®å ´ååä¸LANå ã§16msã ã£ãããï¼ãã¡ã§ä½¿ã£ã¦ããã®ã¯httpsã§ã¯ãªãhttpã ããã©ï¼ã大ä½åç¨åº¦ã®ã³ã¹ããªãã ãªã¨ã
ããã¯ã¨ã³ãã«WebAPIã使ã£ãã¢ããªã±ã¼ã·ã§ã³ãçµãå ´åã¯ãAPIã³ã¼ã«ã«ãããããã®ã³ã¹ãæããã£ã¦è¨è¨ããå¿ è¦ãããã¨ãããã¾ãã